Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Last active June 17, 2021 12:52
Show Gist options
  • Save xuwei-k/43627fa1da479916fcd554e4cacff4c1 to your computer and use it in GitHub Desktop.
Save xuwei-k/43627fa1da479916fcd554e4cacff4c1 to your computer and use it in GitHub Desktop.
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