Scala Programming Language
  1. Scala Programming Language
  2. SI-5859

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

    Details

      Description

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

        Issue Links

          Activity

          Hide
          Paul Phillips added a comment -

          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.

          Show
          Paul Phillips added a comment - 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.
          Hide
          Jason Zaugg added a comment -

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

          Show
          Jason Zaugg added a comment - 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").
          Hide
          Paul Phillips added a comment -

          If you do, it will LGTM.

          Show
          Paul Phillips added a comment - If you do, it will LGTM.
          Show
          Jason Zaugg added a comment - It's a tad noisy: https://github.com/retronym/scala/commit/3bfb6830#commitcomment-1949765
          Hide
          Adriaan Moors added a comment -

          reopening for 2.10.1-RC1 backport

          Show
          Adriaan Moors added a comment - reopening for 2.10.1-RC1 backport

            People

            • Assignee:
              Paul Phillips
              Reporter:
              Paul Phillips
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development