@@ -1505,33 +1505,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
15051505 false
15061506 }
15071507
1508- // This & will try to preserve the FromJavaObjects type in upper bounds
1509- // For example, (? <: FromJavaObjects | Null) & (? <: Any),
1510- // we want to get (? <: FromJavaObjects | Null) intead of (? <: Any),
1511- // because we may check FromJavaObjects | Null <:< Object | Null later.
1512- def bounds_& (tp1 : TypeBounds , tp2 : TypeBounds ) =
1513- if tp1.hi.containsFromJavaObject
1514- && (tp1.hi frozen_<:< tp2.hi)
1515- && (tp2.lo frozen_<:< tp1.lo) then
1516- // FromJavaObject in tp1.hi guarantees tp2.hi <:< tp1.hi
1517- // prefer tp1 if FromJavaObject is in its hi
1518- tp1
1519- else if tp2.hi.containsFromJavaObject
1520- && (tp2.hi frozen_<:< tp1.hi)
1521- && (tp1.lo frozen_<:< tp2.lo) then
1522- // Similarly, prefer tp2 if FromJavaObject is in its hi
1523- tp2
1524- else
1525- // Use regular & to solve other cases
1526- tp1 & tp2
1527-
15281508 def isSubArg (arg1 : Type , arg2 : Type ): Boolean = arg2 match {
15291509 case arg2 : TypeBounds =>
15301510 val arg1norm = arg1 match {
15311511 case arg1 : TypeBounds =>
15321512 tparam match {
1533- case tparam : Symbol =>
1534- bounds_&(arg1, paramBounds(tparam))
1513+ case tparam : Symbol => arg1 & paramBounds(tparam)
15351514 case _ => arg1 // This case can only arise when a hk-type is illegally instantiated with a wildcard
15361515 }
15371516 case _ => arg1
@@ -2062,6 +2041,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
20622041 else if (! tp2.exists) tp1
20632042 else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp2
20642043 else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1) then tp1
2044+ else if tp1.isFromJavaObject && ! tp2.isLambdaSub then tp2
2045+ else if tp2.isFromJavaObject && ! tp1.isLambdaSub then tp1
20652046 else tp2 match
20662047 case tp2 : LazyRef =>
20672048 glb(tp1, tp2.ref)
@@ -2110,6 +2091,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
21102091 if (tp1 eq tp2) tp1
21112092 else if (! tp1.exists) tp1
21122093 else if (! tp2.exists) tp2
2094+ else if tp1.isFromJavaObject && ! tp2.isLambdaSub then tp1
2095+ else if tp2.isFromJavaObject && ! tp1.isLambdaSub then tp2
21132096 else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp1
21142097 else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1) then tp2
21152098 else
0 commit comments