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 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 commented May 31, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5859?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Jun 5, 2012

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

@scabug
Copy link
Author

scabug commented Jun 5, 2012

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

@scabug
Copy link
Author

scabug commented Oct 3, 2012

@retronym said:
I'm working on a fix here: https://github.com/retronym/scala/compare/ticket/5989-2

@scabug
Copy link
Author

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@8886d22cd6

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

@scabug
Copy link
Author

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

@scabug
Copy link
Author

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.

@scabug
Copy link
Author

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").

@scabug
Copy link
Author

scabug commented Oct 3, 2012

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

@scabug
Copy link
Author

scabug commented Oct 4, 2012

@retronym said:
It's a tad noisy:

retronym/scala@3bfb6830#commitcomment-1949765

@scabug
Copy link
Author

scabug commented Jan 22, 2013

@adriaanm said:
reopening for 2.10.1-RC1 backport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants