@@ -3455,37 +3455,10 @@ class Typer extends Namer
34553455
34563456 // try an implicit conversion
34573457 val prevConstraint = ctx.typerState.constraint
3458- def recover (failure : SearchFailureType ) = {
3459- def canTryGADTHealing : Boolean = {
3460- def isDummy = tree.hasAttachment(dummyTreeOfType.IsDummyTree )
3461- tryGadtHealing // allow GADT healing only once to avoid a loop
3462- && ctx.gadt.nonEmpty // GADT healing only makes sense if there are GADT constraints present
3463- && ! isDummy // avoid healing a dummy tree as it can lead to an error in a very specific case
3464- }
3465-
3458+ def recover (failure : SearchFailureType ) =
34663459 if (isFullyDefined(wtp, force = ForceDegree .all) &&
34673460 ctx.typerState.constraint.ne(prevConstraint)) readapt(tree)
3468- else if (canTryGADTHealing) {
3469- // try recovering with a GADT approximation
3470- // note: this seems be be important only in a very specific case
3471- // where we select a member from so
3472- val nestedCtx = ctx.fresh.setNewTyperState()
3473- val ascribed = tpd.Typed (tree, TypeTree (gadtApprox))
3474- val res =
3475- readapt(
3476- tree = ascribed,
3477- shouldTryGadtHealing = false ,
3478- )(using nestedCtx)
3479- if (! nestedCtx.reporter.hasErrors) {
3480- // GADT recovery successful
3481- nestedCtx.typerState.commit()
3482- res
3483- } else {
3484- // otherwise fail with the error that would have been reported without the GADT recovery
3485- err.typeMismatch(tree, pt, failure)
3486- }
3487- } else err.typeMismatch(tree, pt, failure)
3488- }
3461+ else err.typeMismatch(tree, pt, failure)
34893462
34903463 if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.typeOpt.isValueType then
34913464 if pt.isRef(defn.AnyValClass ) || pt.isRef(defn.ObjectClass ) then
0 commit comments