@@ -2186,25 +2186,23 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
2186
2186
}
2187
2187
case _ =>
2188
2188
}
2189
- // try to fully instantiate type
2190
- { val localCtx = ctx.fresh.setNewTyperState
2191
- val prevConstraint = localCtx.typerState.constraint
2192
- if (isFullyDefined(wtp, force = ForceDegree .all)(localCtx) &&
2193
- localCtx.typerState.constraint.ne(prevConstraint)) {
2194
- val tree1 = adapt(tree, pt, original)(localCtx)
2195
- if (! localCtx.reporter.hasErrors) {
2196
- localCtx.typerState.commit()
2197
- return tree1
2198
- }
2199
- }
2200
- }
2201
2189
// try an implicit conversion
2202
2190
inferView(tree, pt) match {
2203
2191
case SearchSuccess (inferred, _, _, _) =>
2204
2192
adapt(inferred, pt)(ctx.retractMode(Mode .ImplicitsEnabled ))
2205
2193
case failure : SearchFailure =>
2206
2194
if (pt.isInstanceOf [ProtoType ] && ! failure.isInstanceOf [AmbiguousImplicits ]) tree
2207
- else err.typeMismatch(tree, pt, failure)
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)
2208
2206
}
2209
2207
}
2210
2208
0 commit comments