Skip to content

Commit 9c2e3d9

Browse files
Avoid adding NoSymbol to gadt constraints in TypeOps.instantiateToSubType (#15965)
fixes lampepfl#15964
2 parents ac74982 + ba75f19 commit 9c2e3d9

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
@@ -851,7 +851,7 @@ object TypeOps:
851851

852852
val getAbstractSymbols = new TypeAccumulator[List[Symbol]]:
853853
def apply(xs: List[Symbol], tp: Type) = tp.dealias match
854-
case tp: TypeRef if !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp)
854+
case tp: TypeRef if tp.symbol.exists && !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp)
855855
case tp => foldOver(xs, tp)
856856
val syms2 = getAbstractSymbols(Nil, tp2).reverse
857857
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)