Skip to content
This repository has been 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

Open
durban opened this issue May 14, 2017 · 0 comments
Open

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

durban opened this issue May 14, 2017 · 0 comments

Comments

@durban
Copy link

durban commented May 14, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant