@@ -744,8 +744,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
744744 }
745745
746746 def tryBaseType (cls2 : Symbol ) = {
747+ val allowBaseType = ! caseLambda.exists || (tp1 match {
748+ case tp : TypeRef if tp.symbol.isClass => true
749+ case AppliedType (tycon : TypeRef , _) if tycon.symbol.isClass => true
750+ case _ => false
751+ })
747752 val base = nonExprBaseType(tp1, cls2)
748- if (base.exists && ( base `ne` tp1))
753+ if (base.exists && base.ne( tp1) && allowBaseType )
749754 isSubType(base, tp2, if (tp1.isRef(cls2)) approx else approx.addLow) ||
750755 base.isInstanceOf [OrType ] && fourthTry
751756 // if base is a disjunction, this might have come from a tp1 type that
@@ -764,7 +769,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
764769 || narrowGADTBounds(tp1, tp2, approx, isUpper = true ))
765770 && (tp2.isAny || GADTusage (tp1.symbol))
766771
767- isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
772+ ! caseLambda.exists && isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
768773 case _ =>
769774 // `Mode.RelaxedOverriding` is only enabled when checking Java overriding
770775 // in explicit nulls, and `Null` becomes a bottom type, which allows
@@ -2535,8 +2540,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25352540 def fullyInstantiated (tp : Type ): Boolean = new TypeAccumulator [Boolean ] {
25362541 override def apply (x : Boolean , t : Type ) =
25372542 x && {
2538- t match {
2539- case tp : TypeRef if tp.symbol.isAbstractOrParamType => false
2543+ t.dealias match {
2544+ case tp : TypeRef if ! tp.symbol.isClass => false
25402545 case _ : SkolemType | _ : TypeVar | _ : TypeParamRef => false
25412546 case _ => foldOver(x, t)
25422547 }
0 commit comments