-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4785: Change typing rule for wildcard star args #5577
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
3204913
to
d52125b
Compare
@@ -91,12 +96,10 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase => | |||
private def seqToArray(tree: Tree, pt: Type)(implicit ctx: Context): Tree = tree match { | |||
case SeqLiteral(elems, elemtpt) => | |||
JavaSeqLiteral(elems, elemtpt) | |||
case app@Apply(fun, args) if defn.WrapArrayMethods().contains(fun.symbol) => // rewrite a call to `wrapXArray(arr)` to `arr` |
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.
Why was this optimization dropped?
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.
It is no longer needed. When calling into java repeated we used to insert an implicit conversion from Array
to Seq
that we later reverted. For example:
def test(xs: Array[String]) = Paths.get("Hello", xs: _*)
Before this patch:
// after frontend:
def test(xs: Array[String]) = Paths.get("Hello", wrapRefArray[String](xs):String*)
// after elimRepeated
def test(xs: Array[String]): = Paths.get("Hello", xs)
After this patch:
// after frontend:
def test(xs: Array[String]) = Paths.get("Hello", xs:String*) // no more call to wrapRefArray
// after elimRepeated
def test(xs: Array[String]): = Paths.get("Hello", xs)
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.
Thanks for explaining!
We typecheck them without expected type to avoid relying on the implicit conversion from Array to Seq defined in Predef. ElimRepeated does the necessary adaptations (i.e. seqToArray and arrayToSeq conversions).
This is not necessary anymore after scala#5403
d52125b
to
47d969f
Compare
Comments addressed |
We typecheck them without expected type to avoid relying on the implicit
conversion from Array to Seq defined in Predef. ElimRepeated does the
necessary adaptations (i.e. seqToArray and arrayToSeq conversions).