-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Type inference of Array receiver with extension method #10255
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
Comments
I think that dotty's behavior is reasonable. There's some funky behavior with Nothing avoidance in Scala 2 that is not repeated. It seems this kicks in here. Is there are reasonable code sample where this matters? |
Two changes from Scala 2 are
The second expression fails because of The first difference might be a Scala 3 feature. |
We should just completely forbid |
I agree on forbidding It would be nice to infer |
I don't know if it's related, but the following 2D array initialization seems to fail. Starting scala3 REPL...
Scala compiler version 3.0.0-M3 -- Copyright 2002-2020, LAMP/EPFL
scala> val c: Array[Array[Int]] = Array(new Array(5))
1 |val c: Array[Array[Int]] = Array(new Array(5))
| ^^^^^^^^^^^^
| Found: Array[Nothing]
| Required: Array[Int] Can be inferred in Scala 2.13.4. Welcome to Scala 2.13.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_202).
Type in expressions for evaluation. Or try :help.
scala> val c: Array[Array[Int]] = Array(new Array(5))
val c: Array[Array[Int]] = Array(Array(0, 0, 0, 0, 0)) |
Minimized code
Output in Scala 2
Expectation
Array type inferred as in Scala 2.
Not sure about the component type of
Array[Nothing]
. Best of all would be to ensure statically that the array is of length zero.There are related issues, but this is "nothing fancy," just "plumbing."
Fancy[Nothing]
.Noticed at scala/scala#9275 (comment)
The text was updated successfully, but these errors were encountered: