-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:inlinearea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcitype:bug
Description
Compiler version
3.4.0
Minimized code
sealed abstract class Parent // The warning goes away if `sealed` is removed
class A extends Parent
class B extends Parent
inline def matchAs[T <: Parent](p: Parent): Unit = p match // The type bound is necessary
case p: T =>
case _ => println("unreachable case reached") // Warning here: "Unreachable case except for null [...]"
end matchAs
@main def main: Unit =
matchAs[A](new B)
end main
Output
Compilation Output
[warn] -- [E121] Pattern Match Warning: [...]/inline_poc/src/main/scala/poc.scala:9:9
[warn] 9 | case _ => println("unreachable case reached")
[warn] | ^
[warn] |Unreachable case except for null (if this is intentional, consider writing case null => instead).
[warn] one warning found
Run Output
unreachable case reached
Expectation
No warning should be issued, since the case is reachable.
Notes
The following conditions are required to trigger the warning
Parent
must besealed
T
must be upper bounded
The warning stays even when p
is declared inline
.
bishabosha
Metadata
Metadata
Assignees
Labels
area:inlinearea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcitype:bug