- 
  Notifications
 You must be signed in to change notification settings 
- Fork 1.1k
Utility for printing resolved implicit chain #21878
 
 
 jatcwang
 
 
 
 started this conversation in
 Feature Requests
 
 -
I recently was debugging implicit resolution issues and I found it quite useful to print out the fully resolved implicit chain
This is the basic implementation I had:
import scala.quoted.*
inline def printResolvedImplicit[A]: Unit =
 ${ printResolvedImplicitImpl[A] }
private def printResolvedImplicitImpl[A](using quotes: Quotes, t: Type[A]): Expr[Unit] =
 import quotes.reflect.*
 Expr.summon[A].match {
 case Some(ex) => println(ex.asTerm.show(using Printer.TreeCode))
 case None => report.error("Implicit resolution failed")
 }
 '{ () }
Does something exist in the Scala 3 std lib? Is it useful enough to be included?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
 
 Sign up for free
 to join this conversation on GitHub.
 Already have an account?
 Sign in to comment