@@ -701,7 +701,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
701701 return Intrinsics .codeOf(arg, call.srcPos)
702702 case _ =>
703703
704- // Special handling of `constValue[T]` and `constValueOpt[T]`
704+ // Special handling of `constValue[T]`, `constValueOpt[T], and summonInline [T]`
705705 if (callTypeArgs.length == 1 )
706706 if (inlinedMethod == defn.Compiletime_constValue ) {
707707 val constVal = tryConstValue
@@ -718,6 +718,19 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
718718 else New (defn.SomeClass .typeRef.appliedTo(constVal.tpe), constVal :: Nil )
719719 )
720720 }
721+ else if (inlinedMethod == defn.Compiletime_summonInline ) {
722+ def searchImplicit (tpt : Tree ) =
723+ val evTyper = new Typer
724+ val evCtx = ctx.fresh.setTyper(evTyper)
725+ val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)(using evCtx)
726+ evidence.tpe match
727+ case fail : Implicits .SearchFailureType =>
728+ val msg = evTyper.missingArgMsg(evidence, tpt.tpe, " " )
729+ errorTree(tpt, em " $msg" )
730+ case _ =>
731+ evidence
732+ return searchImplicit(callTypeArgs.head)
733+ }
721734
722735 def paramTypess (call : Tree , acc : List [List [Type ]]): List [List [Type ]] = call match
723736 case Apply (fn, args) =>
0 commit comments