-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Change the signature of Array.unapplySeq for the benefits of Scala 3 #9977
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
Conversation
e636e8e
to
38f5cb7
Compare
Fixes scala/scala3#14693, see discussion in the issue.
IIUC, we change the signature of What is the behavior of the following? val xs = Array(1L, true)
val ys = Array(1L, 2L)
def matched(any: Any): Unit =
any match
case Array(x: Long, _*) => println(x)
matched(xs)
matched(ys) I would expect both to match. |
This isn't valid syntax, I assume you mean:
In Scala 3 before this PR, only the first matches. In Scala 3 after this PR, both match. |
(and both still match in Scala 2 after this PR too) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any objection to this; at the same time, I'm not entirely convinced that the problem described by Julien lies here and not in the compiler
To restate what's going on: in general when typing the unapplySeq call we need to instantiate its type parameter as |
... is what I thought until now, but it turns out that in Scala 3 this behavior is specific to unapplies defined in Scala 2 classes, so this might in fact be a compiler bug, mea culpa :). Investigation in scala/scala3#14693 (comment) |
Closing, superceded by scala/scala3#14766 |
Fixes scala/scala3#14693, see discussion in the issue.