diff --git a/src/main/scala-2/TypeNamePlatform.scala b/src/main/scala-2/TypeNamePlatform.scala index a161329..39bd77f 100644 --- a/src/main/scala-2/TypeNamePlatform.scala +++ b/src/main/scala-2/TypeNamePlatform.scala @@ -15,6 +15,7 @@ trait TypeNamePlatform { object TypeNamePlatform { + // https://stackoverflow.com/questions/15649720 def typeName_impl[T](c: Context): c.Expr[TypeName[T]] = { import c.universe._ val TypeApply(_, List(typeTree)) = c.macroApplication diff --git a/src/main/scala-3/TypeNamePlatform.scala b/src/main/scala-3/TypeNamePlatform.scala index 8b074d3..7e413f1 100644 --- a/src/main/scala-3/TypeNamePlatform.scala +++ b/src/main/scala-3/TypeNamePlatform.scala @@ -8,14 +8,15 @@ import scala.quoted._ trait TypeNamePlatform { - transparent inline given instance[A] as TypeName[A] = ${TypeNamePlatform.impl[A]} + inline given [A] as TypeName[A] = + ${TypeNamePlatform.impl[A]} } object TypeNamePlatform { - def impl[A](using t: Type[A], ctx: QuoteContext): Expr[TypeName[A]] = { + // https://users.scala-lang.org/t/obtaining-the-name-of-a-type-scala-3/6902/7 + def impl[A](using t: Type[A], ctx: QuoteContext): Expr[TypeName[A]] = '{TypeName[A](${Expr(t.show)})} - } }