We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
scala> def test[A]: List[Int] | A => Int = { case ls: List[Int] => ls.head case _ => 0 } def test[A] => List[Int] | A => Int scala> test(List("oops")) java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:103)
The definition of test should at least yield a warning like "erased type argument Int in type pattern List[Int] is unchecked".
test
Int
List[Int]
The text was updated successfully, but these errors were encountered:
Note that even the following passes the type checker without a warning (at least in the REPL):
scala> def test: List[Int]|List[String] => Int = { case ls: List[Int] => ls.head case _ => 0 } def test List[Int] | List[String] => Int scala> test(List("oops")) java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:103)
Sorry, something went wrong.
Fix scala#5826: specialize union types to avoid constraint cut
426b18c
Merge pull request #5858 from dotty-staging/fix-5826
71dbcab
Fix #5826: specialize union types to avoid constraint cut
liufengyun
No branches or pull requests
The definition of
test
should at least yield a warning like "erased type argumentInt
in type patternList[Int]
is unchecked".The text was updated successfully, but these errors were encountered: