@@ -3398,34 +3398,10 @@ class Typer extends Namer
3398
3398
3399
3399
// try an implicit conversion
3400
3400
val prevConstraint = ctx.typerState.constraint
3401
- def recover (failure : SearchFailureType ) = {
3402
- def canTryGADTHealing : Boolean = {
3403
- val isDummy = tree.hasAttachment(dummyTreeOfType.IsDummyTree )
3404
- tryGadtHealing // allow GADT healing only once to avoid a loop
3405
- && ctx.gadt.nonEmpty // GADT healing only makes sense if there are GADT constraints present
3406
- && ! isDummy // avoid healing a dummy tree as it can lead to an error in a very specific case
3407
- }
3408
-
3401
+ def recover (failure : SearchFailureType ) =
3409
3402
if (isFullyDefined(wtp, force = ForceDegree .all) &&
3410
3403
ctx.typerState.constraint.ne(prevConstraint)) readapt(tree)
3411
- else if (canTryGADTHealing) {
3412
- // try recovering with a GADT approximation
3413
- val nestedCtx = ctx.fresh.setNewTyperState()
3414
- val res =
3415
- readapt(
3416
- tree = tpd.Typed (tree, TypeTree (Inferencing .approximateGADT(wtp))),
3417
- shouldTryGadtHealing = false ,
3418
- )(using nestedCtx)
3419
- if (! nestedCtx.reporter.hasErrors) {
3420
- // GADT recovery successful
3421
- nestedCtx.typerState.commit()
3422
- res
3423
- } else {
3424
- // otherwise fail with the error that would have been reported without the GADT recovery
3425
- err.typeMismatch(tree, pt, failure)
3426
- }
3427
- } else err.typeMismatch(tree, pt, failure)
3428
- }
3404
+ else err.typeMismatch(tree, pt, failure)
3429
3405
if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.typeOpt.isValueType then
3430
3406
if pt.isRef(defn.AnyValClass ) || pt.isRef(defn.ObjectClass ) then
3431
3407
ctx.error(em " the result of an implicit conversion must be more specific than $pt" , tree.sourcePos)
0 commit comments