Skip to content

Commit 80d0e17

Browse files
committed
Drop special case skipping singletons in TypeComparer
1 parent d2d46b3 commit 80d0e17

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,11 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
573573
}
574574
compareTypeLambda
575575
case OrType(tp21, tp22) =>
576-
val tp1a = tp1.widenDealiasKeepRefiningAnnots
576+
val tp1w = tp1.widen
577+
val tp1a = tp1w.dealiasKeepRefiningAnnots
577578
if (tp1a ne tp1)
578579
// Follow the alias; this might avoid truncating the search space in the either below
579-
// Note that it's safe to widen here because singleton types cannot be part of `|`.
580-
return recur(tp1a, tp2)
580+
return recur(tp1a, tp2) || (tp1w ne tp1) && isSubType(tp1w, tp2, approx.addLow)
581581

582582
// Rewrite T1 <: (T211 & T212) | T22 to T1 <: (T211 | T22) and T1 <: (T212 | T22)
583583
// and analogously for T1 <: T21 | (T221 & T222)
@@ -2213,6 +2213,11 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
22132213
super.isSubType(tp1, tp2, approx)
22142214
}
22152215

2216+
override def recur(tp1: Type, tp2: Type): Boolean =
2217+
traceIndented(s"${show(tp1)} <:< ${show(tp2)} recur ${if (frozenConstraint) " frozen" else ""}") {
2218+
super.recur(tp1, tp2)
2219+
}
2220+
22162221
override def hasMatchingMember(name: Name, tp1: Type, tp2: RefinedType): Boolean =
22172222
traceIndented(s"hasMatchingMember(${show(tp1)} . $name, ${show(tp2.refinedInfo)}), member = ${show(tp1.member(name).info)}") {
22182223
super.hasMatchingMember(name, tp1, tp2)

0 commit comments

Comments
 (0)