Skip to content

Commit e7f45a3

Browse files
authored
Backport "Avoid adding NoSymbol to gadt constraints in TypeOps.instantiateToSubType" (#16047)
Backports #15965
2 parents 17e6a6a + 97f6078 commit e7f45a3

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
@@ -854,7 +854,7 @@ object TypeOps:
854854

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