Skip to content

Add regression test #11519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/run-macros/i11161.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Shape$Circle
Shape$Circle
11 changes: 11 additions & 0 deletions tests/run-macros/i11161/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import scala.quoted._
import scala.reflect.ClassTag

inline def showType[T]: String = ${ showTypeImpl[T] }

private def showTypeImpl[T: Type](using Quotes): Expr[String] =
Expr.summon[ClassTag[T]] match
case Some(ct) => '{ $ct.runtimeClass.getName }
case None =>
import quotes.reflect._
report.throwError(s"Unable to find a ClassTag for type ${Type.show[T]}", Position.ofMacroExpansion)
8 changes: 8 additions & 0 deletions tests/run-macros/i11161/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum Shape:
case Square(width: Int, height: Int) extends Shape
case Circle(radius: Int) extends Shape

@main def Test: Unit =
println(showType[Shape.Circle])
println(classOf[Shape.Circle].getName)