Skip to content

Commit

Permalink
Use type name printer of the main source in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarao committed Nov 7, 2023
1 parent ca9ca82 commit 310970a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,12 @@ object Macros {
}
}

private def typeNameOfImpl[T: Type](using Quotes): Expr[String] =
Expr(Type.show[T])
private def typeNameOfImpl[T: Type](using Quotes): Expr[String] = {
import quotes.reflect.*

val typeName = TypeRepr.of[T].show(using Printer.TypeReprShortCode)
Expr(typeName)
}

inline def typeNameOf[T]: String = ${ typeNameOfImpl[T] }
}
11 changes: 1 addition & 10 deletions modules/core/src/test/scala/helper/ShowType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,5 @@

package helper

import scala.quoted.*

def showTypeOfImpl[A: Type](x: Expr[A])(using Quotes): Expr[String] = {
import quotes.reflect.*

val tpe = TypeRepr.of[A].show(using Printer.TypeReprShortCode)
Expr(tpe)
}

inline def showTypeOf[A](x: A): String =
${ showTypeOfImpl('x) }
com.github.tarao.record4s.Macros.typeNameOf[A]

0 comments on commit 310970a

Please sign in to comment.