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