Skip to content

Commit

Permalink
Avoid adding NoSymbol to gadt constraints in TypeOps.instantiateToSub…
Browse files Browse the repository at this point in the history
…Type (#15965)

fixes lampepfl#15964
  • Loading branch information
KacperFKorban authored Sep 4, 2022
2 parents ac74982 + ba75f19 commit 9c2e3d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ object TypeOps:

val getAbstractSymbols = new TypeAccumulator[List[Symbol]]:
def apply(xs: List[Symbol], tp: Type) = tp.dealias match
case tp: TypeRef if !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp)
case tp: TypeRef if tp.symbol.exists && !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp)
case tp => foldOver(xs, tp)
val syms2 = getAbstractSymbols(Nil, tp2).reverse
if syms2.nonEmpty then ctx.gadt.addToConstraint(syms2)
Expand Down
16 changes: 16 additions & 0 deletions tests/pos/i15964.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// scalac: -Werror
sealed trait T
class C extends T

class AClass
type AType = AClass {
type TypeMember <: T
}

def list2Product(
atype: AType,
opt: atype.TypeMember
): Unit =
opt match {
case _: C => ()
}

0 comments on commit 9c2e3d9

Please sign in to comment.