@@ -321,7 +321,7 @@ object SpaceEngine {
321
321
* The types should be atomic (non-decomposable) and unrelated (neither
322
322
* should be a subtype of the other).
323
323
*/
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 ) {
325
325
// Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
326
326
if ! ctx.mode.is(Mode .SafeNulls ) && (tp1.isNullType || tp2.isNullType) then
327
327
// Since projections of types don't include null, intersection with null is empty.
@@ -459,17 +459,8 @@ object SpaceEngine {
459
459
WildcardType
460
460
461
461
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 ))
473
464
tp.derivedAppliedType(erase(tycon, inArray, isValue = false ), args2)
474
465
475
466
case tp @ OrType (tp1, tp2) =>
@@ -640,7 +631,7 @@ object SpaceEngine {
640
631
// For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
641
632
parts.map(tp.derivedAppliedType(_, targs))
642
633
643
- case tp if tp.classSymbol. isDecomposableToChildren =>
634
+ case tp if tp.isDecomposableToChildren =>
644
635
def getChildren (sym : Symbol ): List [Symbol ] =
645
636
sym.children.flatMap { child =>
646
637
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 {
676
667
rec(tp, Nil )
677
668
}
678
669
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,
681
672
* abstract (or a trait) - so its not a sealed concrete class that can be instantiated on its own,
682
673
* has no anonymous children, which we wouldn't be able to name as counter-examples,
683
674
* but does have children.
@@ -686,7 +677,8 @@ object SpaceEngine {
686
677
* A sealed trait with subclasses that then get removed after `refineUsingParent`, decomposes to the empty list.
687
678
* So that's why we consider whether a type has children. */
688
679
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
690
682
691
683
val ListOfNoType = List (NoType )
692
684
val ListOfTypNoType = ListOfNoType .map(Typ (_, decomposed = true ))
0 commit comments