Last active
June 17, 2021 12:52
-
-
Save xuwei-k/43627fa1da479916fcd554e4cacff4c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.quoted.* | |
object SummonDebugMacro { | |
inline def summonDebug[A]: A = ${summonDebugImpl[A]} | |
def summonDebugImpl[A: Type](using q: Quotes): Expr[A] = { | |
import q.reflect.* | |
Expr.summon[A] match { | |
case Some(tree) => | |
println(tree.show) | |
tree | |
case _ => | |
report.throwError("could not find implicit value") | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment