Skip to content

Inlined match statements should not fail on unreachable cases #8967

Closed
@letalvoj

Description

@letalvoj

Minimized code

inline def aToB[T,A,B](t:T,b:B): T|B = t match {
  case _:A => b
  case _:T => t
}

@main def main() = aToB[Int, Double, String](1,"x")

Output

❌ this case is unreachable since type Int is not a subclass of class Double

Expectation

A warning? User of the inlined method would be hardly able to do anything about it if it came from a library.

Moreover, is a dead branch of match statement really worth a compile error? Non-exhaustive matches, which seem more serious to me, are just warnings now.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions