@@ -2518,6 +2518,17 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2518
2518
def decompose (sym : Symbol , tp : Type ): List [Type ] =
2519
2519
sym.children.map(x => refineUsingParent(tp, x)).filter(_.exists)
2520
2520
2521
+ def fullyInstantiated (tp : Type ): Boolean = new TypeAccumulator [Boolean ] {
2522
+ override def apply (x : Boolean , t : Type ) =
2523
+ x && {
2524
+ t match {
2525
+ case tp : TypeRef if tp.symbol.isAbstractOrParamType => false
2526
+ case _ : SkolemType | _ : TypeVar => false
2527
+ case _ => foldOver(x, t)
2528
+ }
2529
+ }
2530
+ }.apply(true , tp)
2531
+
2521
2532
(tp1.dealias, tp2.dealias) match {
2522
2533
case (tp1 : TypeRef , tp2 : TypeRef ) if tp1.symbol == defn.SingletonClass || tp2.symbol == defn.SingletonClass =>
2523
2534
false
@@ -2563,21 +2574,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2563
2574
// doesn't have type tags, meaning that users cannot write patterns
2564
2575
// that do type tests on higher kinded types.
2565
2576
def invariantDisjoint (tp1 : Type , tp2 : Type , tparam : TypeParamInfo ): Boolean =
2566
- covariantDisjoint(tp1, tp2, tparam) || ! isSameType(tp1, tp2) && {
2567
- // We can only trust a "no" from `isSameType` when both
2568
- // `tp1` and `tp2` are fully instantiated.
2569
- def fullyInstantiated (tp : Type ): Boolean = new TypeAccumulator [Boolean ] {
2570
- override def apply (x : Boolean , t : Type ) =
2571
- x && {
2572
- t match {
2573
- case tp : TypeRef if tp.symbol.isAbstractOrParamType => false
2574
- case _ : SkolemType | _ : TypeVar => false
2575
- case _ => foldOver(x, t)
2576
- }
2577
- }
2578
- }.apply(true , tp)
2579
- fullyInstantiated(tp1) && fullyInstantiated(tp2)
2580
- }
2577
+ covariantDisjoint(tp1, tp2, tparam) ||
2578
+ ! isSameType(tp1, tp2) &&
2579
+ fullyInstantiated(tp1) && // We can only trust a "no" from `isSameType` when
2580
+ fullyInstantiated(tp2) // both `tp1` and `tp2` are fully instantiated.
2581
2581
2582
2582
args1.lazyZip(args2).lazyZip(tycon1.typeParams).exists {
2583
2583
(arg1, arg2, tparam) =>
0 commit comments