Closed lrytz closed 1 year ago
Scala 2.13.10
class Out { sealed trait P case class K(x: Int) extends P } class C[O <: Out](val o: O) { import o._ def foo(t: P) = t match { case _: K => 0 } }
leads to
Test.scala:8: warning: match may not be exhaustive. It would fail on the following input: K(_) def foo(t: P) = t match { ^ 1 warning
The bug is in enumerateSealed, which calls approximateAbstracts, which has
enumerateSealed
approximateAbstracts
case TypeRef(pre, sym, _) if sym.isAbstractType => WildcardType
This turns the prefix of C.this.o.P into wildcard, leading to ?#P, and enumerateSealed then returns Out.this.K instead of C.this.o.K.
C.this.o.P
?#P
Out.this.K
C.this.o.K
Scala 2.13.10
leads to
The bug is in
enumerateSealed
, which callsapproximateAbstracts
, which hasThis turns the prefix of
C.this.o.P
into wildcard, leading to?#P
, andenumerateSealed
then returnsOut.this.K
instead ofC.this.o.K
.