Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid adding NoSymbol to gadt constraints in TypeOps.instantiateToSubType #15965

Merged
merged 1 commit into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -852,7 +852,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 => ()
}