Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-3761

resolution fails paramters by-name followed by varargs vs parameter by-name

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0-M3, Scala 2.10.0
    • Component/s: Compiler (Misc)
    • Labels:
      None
    • Environment:

      by-name varargs parameter

      Description

      # cat VarArgs.scala
      class Foo {
        def info0(m: String) { }
        def info0(m: String, args: Any*) { }
       
        def info1(m: =>String) { }
        def info1(m: =>String, args: Any*) { }
      }
      object VarArgs {
        def main(args: Array[String]) {
          val foo = new Foo
          foo.info0("hello")
          foo.info1("world")
        }
      }
      # scalac -version
      Scala compiler version 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL
      # scalac VarArgs.scala
      VarArgs.scala:16: error: ambiguous reference to overloaded definition,
      both method info1 in class Foo of type (m: => String,args: Any*)Unit
      and  method info1 in class Foo of type (m: => String)Unit
      match argument types (java.lang.String)
          foo.info1("world")
              ^
      one error found

      The by-value methods can be handled by not the by-name methods.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                apm A. P. Marki
                Reporter:
                rmemberson Richard Emberson
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: