@@ -1934,43 +1934,40 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1934
1934
else if (! tp2.exists) tp1
1935
1935
else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp2
1936
1936
else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1) then tp1
1937
- else tp2 match { // normalize to disjunctive normal form if possible.
1937
+ else tp2 match
1938
1938
case tp2 : LazyRef =>
1939
1939
glb(tp1, tp2.ref)
1940
- case OrType (tp21, tp22) =>
1941
- tp1 & tp21 | tp1 & tp22
1942
1940
case _ =>
1943
- tp1 match {
1941
+ tp1 match
1944
1942
case tp1 : LazyRef =>
1945
1943
glb(tp1.ref, tp2)
1946
- case OrType (tp11, tp12) =>
1947
- tp11 & tp2 | tp12 & tp2
1948
1944
case _ =>
1949
1945
val tp1a = dropIfSuper(tp1, tp2)
1950
- if ( tp1a ne tp1) glb(tp1a, tp2)
1951
- else {
1946
+ if tp1a ne tp1 then glb(tp1a, tp2)
1947
+ else
1952
1948
val tp2a = dropIfSuper(tp2, tp1)
1953
- if (tp2a ne tp2) glb(tp1, tp2a)
1954
- else tp1 match {
1955
- case tp1 : ConstantType =>
1956
- tp2 match {
1957
- case tp2 : ConstantType =>
1958
- // Make use of the fact that the intersection of two constant types
1959
- // types which are not subtypes of each other is known to be empty.
1960
- // Note: The same does not apply to singleton types in general.
1961
- // E.g. we could have a pattern match against `x.type & y.type`
1962
- // which might succeed if `x` and `y` happen to be the same ref
1963
- // at run time. It would not work to replace that with `Nothing`.
1964
- // However, maybe we can still apply the replacement to
1965
- // types which are not explicitly written.
1966
- NothingType
1949
+ if tp2a ne tp2 then glb(tp1, tp2a)
1950
+ else tp2 match // normalize to disjunctive normal form if possible.
1951
+ case OrType (tp21, tp22) =>
1952
+ tp1 & tp21 | tp1 & tp22
1953
+ case _ =>
1954
+ tp1 match
1955
+ case OrType (tp11, tp12) =>
1956
+ tp11 & tp2 | tp12 & tp2
1957
+ case tp1 : ConstantType =>
1958
+ tp2 match
1959
+ case tp2 : ConstantType =>
1960
+ // Make use of the fact that the intersection of two constant types
1961
+ // types which are not subtypes of each other is known to be empty.
1962
+ // Note: The same does not apply to singleton types in general.
1963
+ // E.g. we could have a pattern match against `x.type & y.type`
1964
+ // which might succeed if `x` and `y` happen to be the same ref
1965
+ // at run time. It would not work to replace that with `Nothing`.
1966
+ // However, maybe we can still apply the replacement to
1967
+ // types which are not explicitly written.
1968
+ NothingType
1969
+ case _ => andType(tp1, tp2)
1967
1970
case _ => andType(tp1, tp2)
1968
- }
1969
- case _ => andType(tp1, tp2)
1970
- }
1971
- }
1972
- }
1973
- }
1974
1971
}
1975
1972
1976
1973
def widenInUnions (using Context ): Boolean =
0 commit comments