@@ -1505,33 +1505,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1505
1505
false
1506
1506
}
1507
1507
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
-
1528
1508
def isSubArg (arg1 : Type , arg2 : Type ): Boolean = arg2 match {
1529
1509
case arg2 : TypeBounds =>
1530
1510
val arg1norm = arg1 match {
1531
1511
case arg1 : TypeBounds =>
1532
1512
tparam match {
1533
- case tparam : Symbol =>
1534
- bounds_&(arg1, paramBounds(tparam))
1513
+ case tparam : Symbol => arg1 & paramBounds(tparam)
1535
1514
case _ => arg1 // This case can only arise when a hk-type is illegally instantiated with a wildcard
1536
1515
}
1537
1516
case _ => arg1
@@ -2062,6 +2041,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2062
2041
else if (! tp2.exists) tp1
2063
2042
else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp2
2064
2043
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
2065
2046
else tp2 match
2066
2047
case tp2 : LazyRef =>
2067
2048
glb(tp1, tp2.ref)
@@ -2110,6 +2091,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2110
2091
if (tp1 eq tp2) tp1
2111
2092
else if (! tp1.exists) tp1
2112
2093
else if (! tp2.exists) tp2
2094
+ else if tp1.isFromJavaObject && ! tp2.isLambdaSub then tp1
2095
+ else if tp2.isFromJavaObject && ! tp1.isLambdaSub then tp2
2113
2096
else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp1
2114
2097
else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1) then tp2
2115
2098
else
0 commit comments