From d093ceead65c716bb56c2f9fea8d2532dde05395 Mon Sep 17 00:00:00 2001 From: Flavio Brasil Date: Fri, 13 Dec 2024 13:46:42 -0800 Subject: [PATCH] [data] fix Render compilation warnings (#928) --- kyo-data/shared/src/main/scala/kyo/Render.scala | 16 ++++++++-------- .../shared/src/test/scala/kyo/MaybeTest.scala | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/kyo-data/shared/src/main/scala/kyo/Render.scala b/kyo-data/shared/src/main/scala/kyo/Render.scala index 87611af51..aa18bf910 100644 --- a/kyo-data/shared/src/main/scala/kyo/Render.scala +++ b/kyo-data/shared/src/main/scala/kyo/Render.scala @@ -1,6 +1,7 @@ package kyo import kyo.Schedule.done +import scala.annotation.nowarn import scala.language.implicitConversions /** Provides Text representation of a type. Needed for customizing how to display opaque types as alternative to toString @@ -20,6 +21,7 @@ object Render extends LowPriorityRenders: import scala.compiletime.* + @nowarn("msg=anonymous") private inline def sumRender[A, M <: scala.deriving.Mirror.ProductOf[A]](label: String, mir: M): Render[A] = val shows = summonAll[Tuple.Map[mir.MirroredElemTypes, Render]] new Render[A]: @@ -43,6 +45,7 @@ object Render extends LowPriorityRenders: end new end sumRender + @nowarn("msg=anonymous") inline given [A](using mir: scala.deriving.Mirror.Of[A]): Render[A] = inline mir match case sumMir: scala.deriving.Mirror.SumOf[?] => val shows = summonAll[Tuple.Map[sumMir.MirroredElemTypes, Render]] @@ -77,15 +80,12 @@ object Render extends LowPriorityRenders: end Render -sealed trait Rendered: - private[kyo] def textValue: Text +type Rendered = Rendered.Value object Rendered: - given [A](using r: Render[A]): Conversion[A, Rendered] with - def apply(a: A): Rendered = - new Rendered: - private[kyo] def textValue: Text = r.asText(a) - end given + opaque type Value <: Text = Text + implicit def apply[A](value: A)(using render: Render[A]): Rendered = + render.asText(value) end Rendered extension (sc: StringContext) @@ -95,6 +95,6 @@ extension (sc: StringContext) val ai = args.iterator var text: Text = pi.next() while ai.hasNext do - text = text + ai.next.textValue + text = text + ai.next text = text + StringContext.processEscapes(pi.next()) text diff --git a/kyo-data/shared/src/test/scala/kyo/MaybeTest.scala b/kyo-data/shared/src/test/scala/kyo/MaybeTest.scala index 3e4d35d4e..42cd9b785 100644 --- a/kyo-data/shared/src/test/scala/kyo/MaybeTest.scala +++ b/kyo-data/shared/src/test/scala/kyo/MaybeTest.scala @@ -538,7 +538,6 @@ class MaybeTest extends Test: "should return 'Present(value)' for Present" in { assert(Present(1).show == "Present(1)") - summon[Conversion[Present[Int], Rendered]] val somat: Rendered = Present(1) assert(t"${Present(1): Present[Int]}".show == "Present(1)") assert(Present("hello").show == "Present(hello)")