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

overloaded alternative of varargs method invoke-blocks intended target if Nothing is inferred #5859

Closed
scabug opened this issue May 31, 2012 · 11 comments

Comments

@scabug
Copy link

@scabug scabug commented May 31, 2012



scala> def f(xs: List[Int], ys: AnyRef*) = () ; def f(xs: AnyRef*) = ()
f: (xs: List[Int], ys: AnyRef*)Unit <and> (xs: AnyRef*)Unit
f: (xs: List[Int], ys: AnyRef*)Unit <and> (xs: AnyRef*)Unit

scala> f()

scala> f(Nil: _*)
<console>:9: error: no `: _*' annotation allowed here
(such annotations are only allowed in arguments to *-parameters)
              f(Nil: _*)
                   ^

scala> f((Nil: List[String]): _*)

scala> f(Array(): _*)
<console>:9: error: no `: _*' annotation allowed here
(such annotations are only allowed in arguments to *-parameters)
              f(Array(): _*)
                       ^

scala> f(Array[String](): _*)
@scabug
Copy link
Author

@scabug scabug commented May 31, 2012

Loading

@scabug
Copy link
Author

@scabug scabug commented Jun 5, 2012

@adriaanm said:
the Array(): _* invocation should be accepted

Loading

@scabug
Copy link
Author

@scabug scabug commented Jun 5, 2012

@paulp said:
(As well as the Nil: _* invocation.)

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 3, 2012

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 3, 2012

@paulp said:
Sorry for not marking it in the ticket, but I fixed this a few days ago.

scala/scala@8886d22

I sort of marked it when I took ownership of it, which usually means I've fixed it locally.

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 3, 2012

@retronym said:
No worries. I don't have a motivating test case for it, but I'm pretty sure isVarArgsOnly should be propagated here: https://github.com/scala/scala/blob/8886d2/src/compiler/scala/tools/nsc/typechecker/Infer.scala#L1651

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 3, 2012

@paulp said:
This must be why I say "Boolean parameters are bad; Booleans with defaults are worse." That kind of error is pretty much assured by the method signature. Additional pull request encouraged.

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 3, 2012

@retronym said:
More generally, recursive methods with defaults are open to this error. I've seen it often enough that I might add a check to Xlint ("recursive call should not use defaults").

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 3, 2012

@paulp said:
If you do, it will LGTM.

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 4, 2012

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 22, 2013

@adriaanm said:
reopening for 2.10.1-RC1 backport

Loading

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

Successfully merging a pull request may close this issue.

None yet
2 participants