Skip to content

Commit 09b5fa1

Browse files
committed
WIP dive into TypeComparer
1 parent 708a2cf commit 09b5fa1

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
751751
case _ => false
752752
}
753753
case _ => false
754-
comparePaths || isNewSubType(tp1.underlying.widenExpr)
754+
comparePaths || isSubType(tp1.underlying.widenExpr, tp2, approx.addLow)
755755
case tp1: RefinedType =>
756756
isNewSubType(tp1.parent)
757757
case tp1: RecType =>

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)