Skip to content

Spurious exhaustiveness warning for union of tuple types #8690

Closed
@LPTK

Description

@LPTK

Minimized code

class A
class B

def test(x: (A, B) | (B, A)) = x match {
  case (u: A, v) => (u, v)
  case (u: B, v) => (v, u)
}

https://scastie.scala-lang.org/ifiEqLPETBq2eruEbFXfFQ

Output

match may not be exhaustive.
It would fail on pattern case: Tuple2(_, _)

Moreover, the type inferred for v is always Object, whereas it could be more precise here.

Expectation

No warning, and more precise types.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions