diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index b66eef39375f..35a9cab605ae 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3398,34 +3398,10 @@ class Typer extends Namer // try an implicit conversion val prevConstraint = ctx.typerState.constraint - def recover(failure: SearchFailureType) = { - def canTryGADTHealing: Boolean = { - val isDummy = tree.hasAttachment(dummyTreeOfType.IsDummyTree) - tryGadtHealing // allow GADT healing only once to avoid a loop - && ctx.gadt.nonEmpty // GADT healing only makes sense if there are GADT constraints present - && !isDummy // avoid healing a dummy tree as it can lead to an error in a very specific case - } - + def recover(failure: SearchFailureType) = if (isFullyDefined(wtp, force = ForceDegree.all) && ctx.typerState.constraint.ne(prevConstraint)) readapt(tree) - else if (canTryGADTHealing) { - // try recovering with a GADT approximation - val nestedCtx = ctx.fresh.setNewTyperState() - val res = - readapt( - tree = tpd.Typed(tree, TypeTree(Inferencing.approximateGADT(wtp))), - shouldTryGadtHealing = false, - )(using nestedCtx) - if (!nestedCtx.reporter.hasErrors) { - // GADT recovery successful - nestedCtx.typerState.commit() - res - } else { - // otherwise fail with the error that would have been reported without the GADT recovery - err.typeMismatch(tree, pt, failure) - } - } else err.typeMismatch(tree, pt, failure) - } + else err.typeMismatch(tree, pt, failure) if ctx.mode.is(Mode.ImplicitsEnabled) && tree.typeOpt.isValueType then if pt.isRef(defn.AnyValClass) || pt.isRef(defn.ObjectClass) then ctx.error(em"the result of an implicit conversion must be more specific than $pt", tree.sourcePos) diff --git a/tests/neg/i9044.scala b/tests/neg/i9044.scala new file mode 100644 index 000000000000..31515eb34879 --- /dev/null +++ b/tests/neg/i9044.scala @@ -0,0 +1,14 @@ +sealed trait Test[+F[_], +A] extends Product with Serializable + +object Test { + + implicit class Syntax[F[_], A](val self: Test[F, A]) extends AnyVal { + + def fold[B](completed: F[A] => B): B = self match { + case Completed(fa) => completed(fa) // error + } + } + + + final case class Completed[F[_], A](fa: F[A]) extends Test[F, A] +} diff --git a/tests/pos/boundspropagation.scala b/tests/pos/boundspropagation.scala.ignore similarity index 100% rename from tests/pos/boundspropagation.scala rename to tests/pos/boundspropagation.scala.ignore diff --git a/tests/pos/i7044.scala b/tests/pos/i7044.scala.ignore similarity index 100% rename from tests/pos/i7044.scala rename to tests/pos/i7044.scala.ignore