@@ -321,7 +321,7 @@ object SpaceEngine {
321321 * The types should be atomic (non-decomposable) and unrelated (neither
322322 * should be a subtype of the other).
323323 */
324- def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type )(sp : Space )(using Context ): Space = trace(i " atomic intersection: ${AndType (tp1, tp2)}" , debug) {
324+ def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type )(sp : Space )(using Context ): Space = trace(i " atomic intersection: ${AndType (tp1, tp2)}" , debug, show ) {
325325 // Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
326326 if ! ctx.mode.is(Mode .SafeNulls ) && (tp1.isNullType || tp2.isNullType) then
327327 // Since projections of types don't include null, intersection with null is empty.
@@ -459,17 +459,8 @@ object SpaceEngine {
459459 WildcardType
460460
461461 case tp @ AppliedType (tycon, args) =>
462- val args2 =
463- if tycon.isRef(defn.ArrayClass ) then
464- args.map(arg => erase(arg, inArray = true , isValue = false ))
465- else tycon.typeParams.lazyZip(args).map { (tparam, arg) =>
466- if isValue && tparam.paramVarianceSign == 0 then
467- // when matching against a value,
468- // any type argument for an invariant type parameter will be unchecked,
469- // meaning it won't fail to match against anything; thus the wildcard replacement
470- WildcardType
471- else erase(arg, inArray = false , isValue = false )
472- }
462+ val inArray = tycon.isRef(defn.ArrayClass )
463+ val args2 = args.map(arg => erase(arg, inArray = inArray, isValue = false ))
473464 tp.derivedAppliedType(erase(tycon, inArray, isValue = false ), args2)
474465
475466 case tp @ OrType (tp1, tp2) =>
@@ -640,7 +631,7 @@ object SpaceEngine {
640631 // For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
641632 parts.map(tp.derivedAppliedType(_, targs))
642633
643- case tp if tp.classSymbol. isDecomposableToChildren =>
634+ case tp if tp.isDecomposableToChildren =>
644635 def getChildren (sym : Symbol ): List [Symbol ] =
645636 sym.children.flatMap { child =>
646637 if child eq sym then List (sym) // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
@@ -676,8 +667,8 @@ object SpaceEngine {
676667 rec(tp, Nil )
677668 }
678669
679- extension (cls : Symbol )
680- /** A type is decomposable to children if it's sealed,
670+ extension (tp : Type )
671+ /** A type is decomposable to children if it has a simple kind, it 's sealed,
681672 * abstract (or a trait) - so its not a sealed concrete class that can be instantiated on its own,
682673 * has no anonymous children, which we wouldn't be able to name as counter-examples,
683674 * but does have children.
@@ -686,7 +677,8 @@ object SpaceEngine {
686677 * A sealed trait with subclasses that then get removed after `refineUsingParent`, decomposes to the empty list.
687678 * So that's why we consider whether a type has children. */
688679 def isDecomposableToChildren (using Context ): Boolean =
689- cls.is(Sealed ) && cls.isOneOf(AbstractOrTrait ) && ! cls.hasAnonymousChild && cls.children.nonEmpty
680+ val cls = tp.classSymbol
681+ tp.hasSimpleKind && cls.is(Sealed ) && cls.isOneOf(AbstractOrTrait ) && ! cls.hasAnonymousChild && cls.children.nonEmpty
690682
691683 val ListOfNoType = List (NoType )
692684 val ListOfTypNoType = ListOfNoType .map(Typ (_, decomposed = true ))
0 commit comments