Skip to content

Commit ba75f19

Browse files
committed
Avoid adding NoSymbol to gadt constraints in TypeOps.instantiateToSubType
fixes lampepfl#15964
1 parent 8504b8d commit ba75f19

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ object TypeOps:
852852

853853
val getAbstractSymbols = new TypeAccumulator[List[Symbol]]:
854854
def apply(xs: List[Symbol], tp: Type) = tp.dealias match
855-
case tp: TypeRef if !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp)
855+
case tp: TypeRef if tp.symbol.exists && !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp)
856856
case tp => foldOver(xs, tp)
857857
val syms2 = getAbstractSymbols(Nil, tp2).reverse
858858
if syms2.nonEmpty then ctx.gadt.addToConstraint(syms2)

tests/pos/i15964.scala

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// scalac: -Werror
2+
sealed trait T
3+
class C extends T
4+
5+
class AClass
6+
type AType = AClass {
7+
type TypeMember <: T
8+
}
9+
10+
def list2Product(
11+
atype: AType,
12+
opt: atype.TypeMember
13+
): Unit =
14+
opt match {
15+
case _: C => ()
16+
}

0 commit comments

Comments
 (0)