Skip to content

Exhaustivity checker emits spurious warning when matching on Java enum type (2.13.11 regression) #12800

Closed
scala/scala
#10424
@vasilmkd

Description

@vasilmkd

Reproduction steps

git clone git@github.com:vasilmkd/scala-java-enum-regression.git
cd scala-java-enum-regression
sbt compile

https://github.com/vasilmkd/scala-java-enum-regression

Scala version: 2.13.11

Problem (-Werror flag is on)

[error] <path>/scala-java-enum-regression/src/main/scala/main.scala:5:23: match may not be exhaustive.
[error] It would fail on the following inputs: (_ : com.intellij.openapi.compiler.CompilerMessageCategory$1), (_ : com.intellij.openapi.compiler.CompilerMessageCategory$2), (_ : com.intellij.openapi.compiler.CompilerMessageCategory$3), (_ : com.intellij.openapi.compiler.CompilerMessageCategory$4)
[error]     val messageType = category match {
[error]                       ^
[error] one error found

Further context

  1. Scala 2.13.10 does not exhibit this behavior.
  2. Compiling using Scala 3.3.0 and Scala 2.12.18 works fine.
  3. The warning/error is not issued if the same Java source code is copied into a .java file and compiled using sbt. It is necessary for this enum to be published in a library. (Might be a problem with classfile decompilation?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions