Skip to content

Commit 0bdbb4e

Browse files
committed
Guard against NoSymbol in compareGADT
Without the guard the test case crashes with an assert attempting get the owner of NoSymbol.
1 parent fbc9d0a commit 0bdbb4e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
678678
narrowGADTBounds(tp1, tp2, approx, isUpper = true)) &&
679679
GADTusage(tp1.symbol)
680680
}
681-
isSubType(hi1, tp2, approx.addLow) || compareGADT
681+
isSubType(hi1, tp2, approx.addLow) || ((tp1.symbol ne NoSymbol) && compareGADT)
682682
case _ =>
683683
def isNullable(tp: Type): Boolean = tp.widenDealias match {
684684
case tp: TypeRef => tp.symbol.isNullableClass

tests/pos/dep-match.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test {
2+
type Foo = Int { type U }
3+
type Bar[T] = T match {
4+
case Unit => Unit
5+
}
6+
inline def baz(foo: Foo): Unit = {
7+
val v: Bar[foo.U] = ???
8+
}
9+
}

0 commit comments

Comments
 (0)