Skip to content

Commit 778827e

Browse files
committed
Opportunistically merge A & A -> A and B | B -> B in <:<
Cases like these (in fact one of the operads was a type variable the other its underlying polyparam) arose in pos/overloads.scala and caused deep subtype recursions.
1 parent d9d64f1 commit 778827e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
215215
compareSuper
216216
case AndType(tp21, tp22) =>
217217
isSubType(tp1, tp21) && isSubType(tp1, tp22)
218+
case OrType(tp21, tp22) =>
219+
if (tp21.stripTypeVar eq tp22.stripTypeVar) isSubType(tp1, tp21)
220+
else thirdTry(tp1, tp2)
218221
case TypeErasure.ErasedValueType(cls2, underlying2) =>
219222
def compareErasedValueType = tp1 match {
220223
case TypeErasure.ErasedValueType(cls1, underlying1) =>
@@ -277,6 +280,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
277280
isSubType(tp1.ref, tp2)
278281
case tp1: AnnotatedType =>
279282
isSubType(tp1.tpe, tp2)
283+
case AndType(tp11, tp12) =>
284+
if (tp11.stripTypeVar eq tp12.stripTypeVar) isSubType(tp11, tp2)
285+
else thirdTry(tp1, tp2)
280286
case OrType(tp11, tp12) =>
281287
isSubType(tp11, tp2) && isSubType(tp12, tp2)
282288
case ErrorType =>

0 commit comments

Comments
 (0)