@@ -330,7 +330,7 @@ object SpaceEngine {
330330 * The types should be atomic (non-decomposable) and unrelated (neither
331331 * should be a subtype of the other).
332332 */
333- def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type )(sp : Space )(using Context ): Space = trace(i " atomic intersection: ${AndType (tp1, tp2)}" , debug) {
333+ def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type )(sp : Space )(using Context ): Space = trace(i " atomic intersection: ${AndType (tp1, tp2)}" , debug, show ) {
334334 // Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
335335 if ! ctx.mode.is(Mode .SafeNulls ) && (tp1.isNullType || tp2.isNullType) then
336336 // Since projections of types don't include null, intersection with null is empty.
@@ -468,17 +468,8 @@ object SpaceEngine {
468468 WildcardType
469469
470470 case tp @ AppliedType (tycon, args) =>
471- val args2 =
472- if tycon.isRef(defn.ArrayClass ) then
473- args.map(arg => erase(arg, inArray = true , isValue = false ))
474- else tycon.typeParams.lazyZip(args).map { (tparam, arg) =>
475- if isValue && tparam.paramVarianceSign == 0 then
476- // when matching against a value,
477- // any type argument for an invariant type parameter will be unchecked,
478- // meaning it won't fail to match against anything; thus the wildcard replacement
479- WildcardType
480- else erase(arg, inArray = false , isValue = false )
481- }
471+ val inArray = tycon.isRef(defn.ArrayClass )
472+ val args2 = args.map(arg => erase(arg, inArray = inArray, isValue = false ))
482473 tp.derivedAppliedType(erase(tycon, inArray, isValue = false ), args2)
483474
484475 case tp @ OrType (tp1, tp2) =>
@@ -642,7 +633,7 @@ object SpaceEngine {
642633 // For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
643634 parts.map(tp.derivedAppliedType(_, targs))
644635
645- case tp if tp.classSymbol. isDecomposableToChildren =>
636+ case tp if tp.isDecomposableToChildren =>
646637 def getChildren (sym : Symbol ): List [Symbol ] =
647638 sym.children.flatMap { child =>
648639 if child eq sym then List (sym) // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
@@ -678,8 +669,8 @@ object SpaceEngine {
678669 rec(tp, Nil )
679670 }
680671
681- extension (cls : Symbol )
682- /** A type is decomposable to children if it's sealed,
672+ extension (tp : Type )
673+ /** A type is decomposable to children if it has a simple kind, it 's sealed,
683674 * abstract (or a trait) - so its not a sealed concrete class that can be instantiated on its own,
684675 * has no anonymous children, which we wouldn't be able to name as counter-examples,
685676 * but does have children.
@@ -688,7 +679,8 @@ object SpaceEngine {
688679 * A sealed trait with subclasses that then get removed after `refineUsingParent`, decomposes to the empty list.
689680 * So that's why we consider whether a type has children. */
690681 def isDecomposableToChildren (using Context ): Boolean =
691- cls.is(Sealed ) && cls.isOneOf(AbstractOrTrait ) && ! cls.hasAnonymousChild && cls.children.nonEmpty
682+ val cls = tp.classSymbol
683+ tp.hasSimpleKind && cls.is(Sealed ) && cls.isOneOf(AbstractOrTrait ) && ! cls.hasAnonymousChild && cls.children.nonEmpty
692684
693685 val ListOfNoType = List (NoType )
694686 val ListOfTypNoType = ListOfNoType .map(Typ (_, decomposed = true ))
0 commit comments