Skip to content

Patter match waring on erased type not needed #3323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolasstucki opened this issue Oct 13, 2017 · 2 comments
Closed

Patter match waring on erased type not needed #3323

nicolasstucki opened this issue Oct 13, 2017 · 2 comments

Comments

@nicolasstucki
Copy link
Contributor

class Foo {
  def foo[A](lss: List[List[A]]): Unit = {
    lss match {
      case xss: List[List[A]] =>
    }
  }
}

produces the following waring

-- [E091] Pattern Match Exhaustivity Warning: Foo.scala:5:16 -------------------
5 |      case xss: List[List[A]] =>
  |                ^^^^^^^^^^^^^
  |       type arguments are not checked since they are eliminated by erasure

even if we know statically that the type will match.

@allanrenucci
Copy link
Contributor

Simpler test case:

class Foo {
  def foo(lss: List[Int]): Unit = {
    lss match {
      case xss: List[Int] =>
    }
  }
}
-- [E091] Pattern Match Exhaustivity Warning: tests/allan/Test.scala:4:16 ------
4 |      case xss: List[Int] =>
  |                ^^^^^^^^^
  |       type arguments are not checked since they are eliminated by erasure

longer explanation available when compiling with `-explain`

@allanrenucci
Copy link
Contributor

I don't think we should emit unchecked warning in pattern matching. Otherwise will have to repeat the work for isInstanceOf checks: #3324.
I believe we can do it once for isInstanceOf checks after we transform pattern match cases to isInstanceOf checks.

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

No branches or pull requests

3 participants