Skip to content

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

Closed

Description

@scabug


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](): _*)

Activity

  1. scabug commented on May 31, 2012

    @scabug
    Author
  2. scabug commented on Jun 5, 2012

    @scabug
    Author

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

  3. scabug commented on Jun 5, 2012

    @scabug
    Author

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

  4. scabug commented on Oct 3, 2012

    @scabug
    Author
  5. scabug commented on Oct 3, 2012

    @scabug
    Author

    @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.

  6. scabug commented on Oct 3, 2012

    @scabug
    Author

    @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

  7. scabug commented on Oct 3, 2012

    @scabug
    Author

    @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.

  8. scabug commented on Oct 3, 2012

    @scabug
    Author

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

  9. scabug commented on Oct 3, 2012

    @scabug
    Author

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

  10. scabug commented on Oct 4, 2012

    @scabug
    Author
  11. scabug commented on Jan 22, 2013

    @scabug
    Author

    @adriaanm said:
    reopening for 2.10.1-RC1 backport

  12. added this to the 2.10.1 milestone on Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions