@@ -330,7 +330,7 @@ object SpaceEngine {
330
330
* The types should be atomic (non-decomposable) and unrelated (neither
331
331
* should be a subtype of the other).
332
332
*/
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 ) {
334
334
// Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1).
335
335
if ! ctx.mode.is(Mode .SafeNulls ) && (tp1.isNullType || tp2.isNullType) then
336
336
// Since projections of types don't include null, intersection with null is empty.
@@ -468,17 +468,8 @@ object SpaceEngine {
468
468
WildcardType
469
469
470
470
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 ))
482
473
tp.derivedAppliedType(erase(tycon, inArray, isValue = false ), args2)
483
474
484
475
case tp @ OrType (tp1, tp2) =>
@@ -642,7 +633,7 @@ object SpaceEngine {
642
633
// For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
643
634
parts.map(tp.derivedAppliedType(_, targs))
644
635
645
- case tp if tp.classSymbol. isDecomposableToChildren =>
636
+ case tp if tp.isDecomposableToChildren =>
646
637
def getChildren (sym : Symbol ): List [Symbol ] =
647
638
sym.children.flatMap { child =>
648
639
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 {
678
669
rec(tp, Nil )
679
670
}
680
671
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,
683
674
* abstract (or a trait) - so its not a sealed concrete class that can be instantiated on its own,
684
675
* has no anonymous children, which we wouldn't be able to name as counter-examples,
685
676
* but does have children.
@@ -688,7 +679,8 @@ object SpaceEngine {
688
679
* A sealed trait with subclasses that then get removed after `refineUsingParent`, decomposes to the empty list.
689
680
* So that's why we consider whether a type has children. */
690
681
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
692
684
693
685
val ListOfNoType = List (NoType )
694
686
val ListOfTypNoType = ListOfNoType .map(Typ (_, decomposed = true ))
0 commit comments