Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

False positive with strict-unsealed-patmat and Java enum (2.11) #149

@durban

Description

@durban

If I have a Java enum like this:

package com.example;

public enum MyEnum {
  FOO,
  BAR,
  BAZ,
}

And I match on it from Scala like this:

package com.example

object Foo {
  
  def foo(e: MyEnum): Int = e match {
    case MyEnum.FOO => 1
    case MyEnum.BAR => 2
    case MyEnum.BAZ => 3
  }
}

I get a warning:

[warn] .../Foo.scala:5: match may not be exhaustive.
[warn] It would fail on the following input: (x: com.example.MyEnum forSome x not in (BAR, BAZ, FOO))
[warn]   def foo(e: MyEnum): Int = e match {
[warn]                             ^

Build options:

scalaVersion := "2.11.11-bin-typelevel-4"
scalaOrganization := "org.typelevel"
scalacOptions += "-Xlint:strict-unsealed-patmat"

Note, that I cannot reproduce the issue with version 2.12.2-bin-typelevel-4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions