@@ -755,21 +755,22 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
755
755
fourthTry
756
756
}
757
757
758
- def tryBaseType (cls2 : Symbol ) = {
759
- val allowBaseType = ! caseLambda.exists || (tp1 match {
760
- case tp : TypeRef if tp.symbol.isClass => true
761
- case AppliedType (tycon : TypeRef , _) if tycon.symbol.isClass => true
762
- case _ => false
763
- })
758
+ def allowBaseTypeForMatchSelector (tp : Type ): Boolean = tp.dealias match
759
+ case tp : TypeRef => tp.symbol.isClass
760
+ case AppliedType (tycon, _) => allowBaseTypeForMatchSelector(tycon)
761
+ case tp : TypeProxy => allowBaseTypeForMatchSelector(tp.superType)
762
+ case tp : AndOrType => allowBaseTypeForMatchSelector(tp.tp1) || allowBaseTypeForMatchSelector(tp.tp2)
763
+ case _ => false
764
+
765
+ def tryBaseType (cls2 : Symbol ) =
764
766
val base = nonExprBaseType(tp1, cls2)
765
- if ( base.exists && base.ne(tp1) && allowBaseType)
766
- isSubType(base, tp2, if (tp1.isRef(cls2)) approx else approx.addLow) ||
767
- base.isInstanceOf [OrType ] && fourthTry
768
- // if base is a disjunction, this might have come from a tp1 type that
769
- // expands to a match type. In this case, we should try to reduce the type
770
- // and compare the redux. This is done in fourthTry
767
+ if base.exists && base.ne(tp1) && ( ! caseLambda.exists || allowBaseTypeForMatchSelector(tp1)) then
768
+ isSubType(base, tp2, if (tp1.isRef(cls2)) approx else approx.addLow)
769
+ || base.isInstanceOf [OrType ] && fourthTry
770
+ // if base is a disjunction, this might have come from a tp1 type that
771
+ // expands to a match type. In this case, we should try to reduce the type
772
+ // and compare the redux. This is done in fourthTry
771
773
else fourthTry
772
- }
773
774
774
775
def fourthTry : Boolean = tp1 match {
775
776
case tp1 : TypeRef =>
0 commit comments