bug
bug copied to clipboard
Better type inference in pattern alternatives
In the following example, the last case is inferred to be of type Any (and therefore does not compile), whereas for both checks T is a common supertype:
object X extends App {
def f(a: Any): Unit = a match {
case a: T1 =>
g(a)
case a @ (_: T with S) =>
g(a)
case a @ (_: T with S | _: T1) =>
g(a)
}
def g(t: T): T = t
}
trait S
trait T
trait T1 extends T
Imported From: https://issues.scala-lang.org/browse/SI-8881?orig=1 Reporter: @sschaef Affected Versions: 2.11.2
Scala 3.3.1 accepts it.