@@ -1969,43 +1969,40 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19691969 else if (! tp2.exists) tp1
19701970 else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || isBottom(tp2) then tp2
19711971 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
19731973 case tp2 : LazyRef =>
19741974 glb(tp1, tp2.ref)
1975- case OrType (tp21, tp22) =>
1976- tp1 & tp21 | tp1 & tp22
19771975 case _ =>
1978- tp1 match {
1976+ tp1 match
19791977 case tp1 : LazyRef =>
19801978 glb(tp1.ref, tp2)
1981- case OrType (tp11, tp12) =>
1982- tp11 & tp2 | tp12 & tp2
19831979 case _ =>
19841980 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
19871983 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)
20022005 case _ => andType(tp1, tp2)
2003- }
2004- case _ => andType(tp1, tp2)
2005- }
2006- }
2007- }
2008- }
20092006 }
20102007
20112008 def widenInUnions (using Context ): Boolean =
0 commit comments