Skip to content

Commit ad5ab27

Browse files
committed
new typer state when infer types before search implicit
1 parent c1f2338 commit ad5ab27

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,11 +4250,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
42504250
else formals1
42514251
implicitArgs(formals2, argIndex + 1, pt)
42524252

4253-
val pt1 = pt.deepenProtoTrans
4254-
if ((pt1 `ne` pt) && (pt1 ne sharpenedPt) && constrainResult(tree.symbol, wtp, pt1)) {
4255-
return implicitArgs(formals, argIndex, pt1)
4253+
val newctx = ctx.fresh.setNewTyperState()
4254+
val pt1 = pt.deepenProtoTrans(using newctx)
4255+
val arg = if ((pt1 `ne` pt) && (pt1 ne sharpenedPt) && constrainResult(tree.symbol, wtp, pt1)(using newctx)) {
4256+
inferImplicitArg(formal, tree.span.endPos)(using newctx)
4257+
} else {
4258+
inferImplicitArg(formal, tree.span.endPos)
42564259
}
4257-
val arg = inferImplicitArg(formal, tree.span.endPos)
42584260
arg.tpe match
42594261
case failed: AmbiguousImplicits =>
42604262
arg :: implicitArgs(formals1, argIndex + 1, pt1)

0 commit comments

Comments
 (0)