@@ -2518,6 +2518,17 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25182518 def decompose (sym : Symbol , tp : Type ): List [Type ] =
25192519 sym.children.map(x => refineUsingParent(tp, x)).filter(_.exists)
25202520
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+
25212532 (tp1.dealias, tp2.dealias) match {
25222533 case (tp1 : TypeRef , tp2 : TypeRef ) if tp1.symbol == defn.SingletonClass || tp2.symbol == defn.SingletonClass =>
25232534 false
@@ -2563,21 +2574,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25632574 // doesn't have type tags, meaning that users cannot write patterns
25642575 // that do type tests on higher kinded types.
25652576 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.
25812581
25822582 args1.lazyZip(args2).lazyZip(tycon1.typeParams).exists {
25832583 (arg1, arg2, tparam) =>
0 commit comments