Skip to content

Commit

Permalink
[data] fix Render compilation warnings (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil authored Dec 13, 2024
1 parent d53aa85 commit d093cee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 8 additions & 8 deletions kyo-data/shared/src/main/scala/kyo/Render.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]:
Expand All @@ -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]]
Expand Down Expand Up @@ -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)
Expand All @@ -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
1 change: 0 additions & 1 deletion kyo-data/shared/src/test/scala/kyo/MaybeTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down

0 comments on commit d093cee

Please sign in to comment.