@@ -2458,26 +2458,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
24582458 isSubRef(tp1, tp2) && isSubRef(tp2, tp1)
24592459 }
24602460
2461- /** If the range `tp1..tp2` consist of a single type, that type, otherwise NoType`.
2462- * This is the case if `tp1 =:= tp2`, but also if `tp1 <:< tp2`, `tp1` is a singleton type,
2463- * and `tp2` derives from `scala.Singleton` (or vice-versa). Examples of the latter case:
2464- *
2465- * "name".type .. Singleton
2466- * "name".type .. String & Singleton
2467- * Singleton .. "name".type
2468- * String & Singleton .. "name".type
2469- *
2470- * All consist of the single type `"name".type`.
2471- */
2472- def singletonInterval (tp1 : Type , tp2 : Type ): Type = {
2473- def isSingletonBounds (lo : Type , hi : Type ) =
2474- lo.isSingleton && hi.derivesFrom(defn.SingletonClass ) && isSubTypeWhenFrozen(lo, hi)
2475- if (isSameTypeWhenFrozen(tp1, tp2)) tp1
2476- else if (isSingletonBounds(tp1, tp2)) tp1
2477- else if (isSingletonBounds(tp2, tp1)) tp2
2478- else NoType
2479- }
2480-
24812461 /** The greatest lower bound of two types */
24822462 def glb (tp1 : Type , tp2 : Type ): Type = // trace(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true):
24832463 if tp1 eq tp2 then tp1
@@ -2583,7 +2563,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25832563 case tparam :: tparamsRest =>
25842564 val arg1 :: args1Rest = args1 : @ unchecked
25852565 val arg2 :: args2Rest = args2 : @ unchecked
2586- val common = singletonInterval (arg1, arg2)
2566+ val common = if isSameTypeWhenFrozen (arg1, arg2) then arg1 else NoType
25872567 val v = tparam.paramVarianceSign
25882568 val lubArg =
25892569 if (common.exists) common
@@ -2615,7 +2595,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
26152595 case tparam :: tparamsRest =>
26162596 val arg1 :: args1Rest = args1 : @ unchecked
26172597 val arg2 :: args2Rest = args2 : @ unchecked
2618- val common = singletonInterval (arg1, arg2)
2598+ val common = if isSameTypeWhenFrozen (arg1, arg2) then arg1 else NoType
26192599 val v = tparam.paramVarianceSign
26202600 val glbArg =
26212601 if (common.exists) common
0 commit comments