Skip to content

Commit

Permalink
Backport "Avoid adding NoSymbol to gadt constraints in TypeOps.instan…
Browse files Browse the repository at this point in the history
…tiateToSubType" (#16047)

Backports #15965
  • Loading branch information
Kordyjan authored Sep 15, 2022
2 parents 17e6a6a + 97f6078 commit e7f45a3
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 @@ -854,7 +854,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 e7f45a3

Please sign in to comment.