@@ -849,13 +849,15 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
849849 def searchImplicit (tpt : Tree ) =
850850 val evTyper = new Typer (ctx.nestingLevel + 1 )
851851 val evCtx = ctx.fresh.setTyper(evTyper)
852- val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)(using evCtx)
853- evidence.tpe match
854- case fail : Implicits .SearchFailureType =>
855- val msg = evTyper.missingArgMsg(evidence, tpt.tpe, " " )
856- errorTree(tpt, em " $msg" )
857- case _ =>
858- evidence
852+ inContext(evCtx) {
853+ val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)
854+ evidence.tpe match
855+ case fail : Implicits .SearchFailureType =>
856+ val msg = evTyper.missingArgMsg(evidence, tpt.tpe, " " )
857+ errorTree(call, em " $msg" )
858+ case _ =>
859+ evidence
860+ }
859861 return searchImplicit(callTypeArgs.head)
860862 }
861863
@@ -1318,17 +1320,19 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
13181320 def searchImplicit (sym : TermSymbol , tpt : Tree ) = {
13191321 val evTyper = new Typer (ctx.nestingLevel + 1 )
13201322 val evCtx = ctx.fresh.setTyper(evTyper)
1321- val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)(using evCtx)
1322- evidence.tpe match {
1323- case fail : Implicits .AmbiguousImplicits =>
1324- report.error(evTyper.missingArgMsg(evidence, tpt.tpe, " " ), tpt.srcPos)
1325- true // hard error: return true to stop implicit search here
1326- case fail : Implicits .SearchFailureType =>
1327- false
1328- case _ =>
1329- // inlining.println(i"inferred implicit $sym: ${sym.info} with $evidence: ${evidence.tpe.widen}, ${evCtx.gadt.constraint}, ${evCtx.typerState.constraint}")
1330- newTermBinding(sym, evidence)
1331- true
1323+ inContext(evCtx) {
1324+ val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)
1325+ evidence.tpe match {
1326+ case fail : Implicits .AmbiguousImplicits =>
1327+ report.error(evTyper.missingArgMsg(evidence, tpt.tpe, " " ), tpt.srcPos)
1328+ true // hard error: return true to stop implicit search here
1329+ case fail : Implicits .SearchFailureType =>
1330+ false
1331+ case _ =>
1332+ // inlining.println(i"inferred implicit $sym: ${sym.info} with $evidence: ${evidence.tpe.widen}, ${evCtx.gadt.constraint}, ${evCtx.typerState.constraint}")
1333+ newTermBinding(sym, evidence)
1334+ true
1335+ }
13321336 }
13331337 }
13341338
0 commit comments