@@ -1781,34 +1781,30 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1781
1781
else if (! tp2.exists) tp2
1782
1782
else if tp1.isAny && ! tp2.isLambdaSub || tp1.isAnyKind || tp2.isRef(NothingClass ) then tp1
1783
1783
else if tp2.isAny && ! tp1.isLambdaSub || tp2.isAnyKind || tp1.isRef(NothingClass ) then tp2
1784
- else tp1 match
1785
- case tp1 : LazyRef => lub(tp1.ref, tp2)
1786
- case _ => tp2 match
1787
- case tp2 : LazyRef => lub(tp1, tp2.ref)
1788
- case _ =>
1789
- def mergedLub : Type = {
1790
- val atoms1 = tp1.atoms(widenOK = true )
1791
- if (atoms1.nonEmpty && ! widenInUnions) {
1792
- val atoms2 = tp2.atoms(widenOK = true )
1793
- if (atoms2.nonEmpty) {
1794
- if (atoms1.subsetOf(atoms2)) return tp2
1795
- if (atoms2.subsetOf(atoms1)) return tp1
1796
- if ((atoms1 & atoms2).isEmpty) return orType(tp1, tp2)
1797
- }
1798
- }
1799
- val t1 = mergeIfSuper(tp1, tp2, canConstrain)
1800
- if (t1.exists) return t1
1784
+ else
1785
+ def mergedLub (tp1 : Type , tp2 : Type ): Type = {
1786
+ val atoms1 = tp1.atoms(widenOK = true )
1787
+ if (atoms1.nonEmpty && ! widenInUnions) {
1788
+ val atoms2 = tp2.atoms(widenOK = true )
1789
+ if (atoms2.nonEmpty) {
1790
+ if (atoms1.subsetOf(atoms2)) return tp2
1791
+ if (atoms2.subsetOf(atoms1)) return tp1
1792
+ if ((atoms1 & atoms2).isEmpty) return orType(tp1, tp2)
1793
+ }
1794
+ }
1795
+ val t1 = mergeIfSuper(tp1, tp2, canConstrain)
1796
+ if (t1.exists) return t1
1801
1797
1802
- val t2 = mergeIfSuper(tp2, tp1, canConstrain)
1803
- if (t2.exists) return t2
1798
+ val t2 = mergeIfSuper(tp2, tp1, canConstrain)
1799
+ if (t2.exists) return t2
1804
1800
1805
- def widen (tp : Type ) = if (widenInUnions) tp.widen else tp.widenIfUnstable
1806
- val tp1w = widen(tp1)
1807
- val tp2w = widen(tp2)
1808
- if ((tp1 ne tp1w) || (tp2 ne tp2w)) lub(tp1w, tp2w)
1809
- else orType(tp1w, tp2w) // no need to check subtypes again
1810
- }
1811
- mergedLub
1801
+ def widen (tp : Type ) = if (widenInUnions) tp.widen else tp.widenIfUnstable
1802
+ val tp1w = widen(tp1)
1803
+ val tp2w = widen(tp2)
1804
+ if ((tp1 ne tp1w) || (tp2 ne tp2w)) lub(tp1w, tp2w)
1805
+ else orType(tp1w, tp2w) // no need to check subtypes again
1806
+ }
1807
+ mergedLub(tp1.stripLazyRef, tp2.stripLazyRef)
1812
1808
}
1813
1809
1814
1810
/** The least upper bound of a list of types */
0 commit comments