Skip to content

Commit 475f015

Browse files
committed
Space: Fix decomposable prefixes of TermRefs
1 parent 454bb6e commit 475f015

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,14 +2182,16 @@ object Types {
21822182

21832183
// --- NamedTypes ------------------------------------------------------------------
21842184

2185-
abstract class NamedType extends CachedProxyType, ValueType { self =>
2185+
abstract class NamedType extends CachedProxyType, ValueType, Product { self =>
21862186

21872187
type ThisType >: this.type <: NamedType
21882188
type ThisName <: Name
21892189

21902190
val prefix: Type
21912191
def designator: Designator
21922192
protected def designator_=(d: Designator): Unit
2193+
def _1: Type
2194+
def _2: Designator
21932195

21942196
assert(NamedType.validPrefix(prefix), s"invalid prefix $prefix")
21952197

@@ -2905,6 +2907,7 @@ object Types {
29052907
def apply(prefix: Type, designator: Name, denot: Denotation)(using Context): NamedType =
29062908
if (designator.isTermName) TermRef.apply(prefix, designator.asTermName, denot)
29072909
else TypeRef.apply(prefix, designator.asTypeName, denot)
2910+
def unapply(tp: NamedType): NamedType = tp
29082911

29092912
def validPrefix(prefix: Type): Boolean = prefix.isValueType || (prefix eq NoPrefix)
29102913
}

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,11 @@ object SpaceEngine {
611611
case tp if !TypeComparer.provablyDisjoint(tp, tpB) => AndType(tp, tpB)
612612

613613
case OrType(tp1, tp2) => List(tp1, tp2)
614-
case _: SingletonType => ListOfNoType
615614
case tp if tp.isRef(defn.BooleanClass) => List(ConstantType(Constant(true)), ConstantType(Constant(false)))
616615
case tp if tp.isRef(defn.UnitClass) => ConstantType(Constant(())) :: Nil
617616
case tp if tp.classSymbol.isAllOf(JavaEnumTrait) => tp.classSymbol.children.map(_.termRef)
618-
case tp @ TypeRef(Parts(parts), _) => parts.map(tp.derivedSelect)
617+
case tp @ NamedType(Parts(parts), _) => parts.map(tp.derivedSelect)
618+
case _: SingletonType => ListOfNoType
619619

620620
case tp @ AppliedType(Parts(parts), targs) if tp.classSymbol.children.isEmpty =>
621621
// It might not obvious that it's OK to apply the type arguments of a parent type to child types.

0 commit comments

Comments
 (0)