Skip to content

Commit 6782df8

Browse files
committed
Simplify logic
1 parent 054065f commit 6782df8

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,18 +2191,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
21912191
case SearchSuccess(inferred, _, _, _) =>
21922192
adapt(inferred, pt)(ctx.retractMode(Mode.ImplicitsEnabled))
21932193
case failure: SearchFailure =>
2194+
val prevConstraint = ctx.typerState.constraint
21942195
if (pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits]) tree
2195-
else {
2196-
// try to fully instantiate type
2197-
val nestedCtx = ctx.fresh.setNewTyperState
2198-
val prevConstraint = nestedCtx.typerState.constraint
2199-
if (isFullyDefined(wtp, force = ForceDegree.all)(nestedCtx) &&
2200-
nestedCtx.typerState.constraint.ne(prevConstraint)) {
2201-
nestedCtx.typerState.commit()
2202-
return adapt(tree, pt, original)
2203-
}
2204-
}
2205-
err.typeMismatch(tree, pt, failure)
2196+
else if (isFullyDefined(wtp, force = ForceDegree.all) &&
2197+
ctx.typerState.constraint.ne(prevConstraint)) adapt(tree, pt, original)
2198+
else err.typeMismatch(tree, pt, failure)
22062199
}
22072200
}
22082201

0 commit comments

Comments
 (0)