@@ -1969,43 +1969,40 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1969
1969
else if (! tp2.exists) tp1
1970
1970
else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp2
1971
1971
else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || isBottom(tp1) then tp1
1972
- else tp2 match { // normalize to disjunctive normal form if possible.
1972
+ else tp2 match
1973
1973
case tp2 : LazyRef =>
1974
1974
glb(tp1, tp2.ref)
1975
- case OrType (tp21, tp22) =>
1976
- tp1 & tp21 | tp1 & tp22
1977
1975
case _ =>
1978
- tp1 match {
1976
+ tp1 match
1979
1977
case tp1 : LazyRef =>
1980
1978
glb(tp1.ref, tp2)
1981
- case OrType (tp11, tp12) =>
1982
- tp11 & tp2 | tp12 & tp2
1983
1979
case _ =>
1984
1980
val tp1a = dropIfSuper(tp1, tp2)
1985
- if ( tp1a ne tp1) glb(tp1a, tp2)
1986
- else {
1981
+ if tp1a ne tp1 then glb(tp1a, tp2)
1982
+ else
1987
1983
val tp2a = dropIfSuper(tp2, tp1)
1988
- if (tp2a ne tp2) glb(tp1, tp2a)
1989
- else tp1 match {
1990
- case tp1 : ConstantType =>
1991
- tp2 match {
1992
- case tp2 : ConstantType =>
1993
- // Make use of the fact that the intersection of two constant types
1994
- // types which are not subtypes of each other is known to be empty.
1995
- // Note: The same does not apply to singleton types in general.
1996
- // E.g. we could have a pattern match against `x.type & y.type`
1997
- // which might succeed if `x` and `y` happen to be the same ref
1998
- // at run time. It would not work to replace that with `Nothing`.
1999
- // However, maybe we can still apply the replacement to
2000
- // types which are not explicitly written.
2001
- NothingType
1984
+ if tp2a ne tp2 then glb(tp1, tp2a)
1985
+ else tp2 match // normalize to disjunctive normal form if possible.
1986
+ case OrType (tp21, tp22) =>
1987
+ tp1 & tp21 | tp1 & tp22
1988
+ case _ =>
1989
+ tp1 match
1990
+ case OrType (tp11, tp12) =>
1991
+ tp11 & tp2 | tp12 & tp2
1992
+ case tp1 : ConstantType =>
1993
+ tp2 match
1994
+ case tp2 : ConstantType =>
1995
+ // Make use of the fact that the intersection of two constant types
1996
+ // types which are not subtypes of each other is known to be empty.
1997
+ // Note: The same does not apply to singleton types in general.
1998
+ // E.g. we could have a pattern match against `x.type & y.type`
1999
+ // which might succeed if `x` and `y` happen to be the same ref
2000
+ // at run time. It would not work to replace that with `Nothing`.
2001
+ // However, maybe we can still apply the replacement to
2002
+ // types which are not explicitly written.
2003
+ NothingType
2004
+ case _ => andType(tp1, tp2)
2002
2005
case _ => andType(tp1, tp2)
2003
- }
2004
- case _ => andType(tp1, tp2)
2005
- }
2006
- }
2007
- }
2008
- }
2009
2006
}
2010
2007
2011
2008
def widenInUnions (using Context ): Boolean =
0 commit comments