Skip to content
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

Array[Null] and Array[Nothing] should be disallowed #7453

Open
scabug opened this issue May 4, 2013 · 5 comments
Open

Array[Null] and Array[Nothing] should be disallowed #7453

scabug opened this issue May 4, 2013 · 5 comments
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented May 4, 2013

See the discussion of #5353 for motivation.

@scabug
Copy link
Author

@scabug scabug commented May 4, 2013

@scabug
Copy link
Author

@scabug scabug commented Apr 9, 2014

@retronym said:
From #8487

scala> if (false) Array("") else Array.empty
 
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;

@scabug
Copy link
Author

@scabug scabug commented Apr 10, 2014

@Atry said:

scala> Array.empty[Nothing]: Array[_ <: String]
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;

@scabug
Copy link
Author

@scabug scabug commented Sep 29, 2016

@Atry said:
Would it possible to erase {{Array[_ <: String]}} to {{Any}} instead of {{Array[String]}}?

@joroKr21
Copy link
Member

@joroKr21 joroKr21 commented Sep 4, 2017

This problem also manifests itself in interop with Java vararg methods:

scala> java.nio.file.Paths.get("/", Nil: _*)
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;

However, I guess here the offending array is inserted by the compiler after the typer phase.
Should (xs: Seq[Nothing]): _* also be disallowed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants