Skip to content

False exhaustivity when GADT is defined in separate file #23817

@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.2

Minimized code

In file1.scala

sealed trait N[T]
case class MakeTuple[T <: Tuple](v: T) extends N[T]

In file2.scala

object test {
  def t[T](expr: N[T]): Any =
    expr match {
      case MakeTuple(_) => ???
    }
}

Output

$ scalac file1.scala && scalac file2.scala
-- [E029] Pattern Match Exhaustivity Warning: file2.scala:3:4 ------------------
3 |    expr match {
  |    ^^^^
  |    match may not be exhaustive.
  |
  |    It would fail on pattern case: MakeTuple(_)
  |
  | longer explanation available when compiling with `-explain`
1 warning found

But compiling in a single scalac call e.g scalac file1.scala file2.scala gives no warnings.

Expectation

Ideally no warning should be produced. But consistently producing the warning would also be an improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions