@@ -2458,26 +2458,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2458
2458
isSubRef(tp1, tp2) && isSubRef(tp2, tp1)
2459
2459
}
2460
2460
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
-
2481
2461
/** The greatest lower bound of two types */
2482
2462
def glb (tp1 : Type , tp2 : Type ): Type = // trace(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true):
2483
2463
if tp1 eq tp2 then tp1
@@ -2583,7 +2563,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2583
2563
case tparam :: tparamsRest =>
2584
2564
val arg1 :: args1Rest = args1 : @ unchecked
2585
2565
val arg2 :: args2Rest = args2 : @ unchecked
2586
- val common = singletonInterval (arg1, arg2)
2566
+ val common = if isSameTypeWhenFrozen (arg1, arg2) then arg1 else NoType
2587
2567
val v = tparam.paramVarianceSign
2588
2568
val lubArg =
2589
2569
if (common.exists) common
@@ -2615,7 +2595,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2615
2595
case tparam :: tparamsRest =>
2616
2596
val arg1 :: args1Rest = args1 : @ unchecked
2617
2597
val arg2 :: args2Rest = args2 : @ unchecked
2618
- val common = singletonInterval (arg1, arg2)
2598
+ val common = if isSameTypeWhenFrozen (arg1, arg2) then arg1 else NoType
2619
2599
val v = tparam.paramVarianceSign
2620
2600
val glbArg =
2621
2601
if (common.exists) common
0 commit comments