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

loading a file with a companion object using :load fails in the REPL

    Details

      Description

      Using Scala 2.9.0, the following code compiles when entering it in the REPL using :paste mode. However, saving it into a file and loading it in the REPL using :load, gives an error:

      case class A(i1: Int, i2: Int)
      
      object A {
        def apply(i: Int): A = A(i, i)
      }
      
      scala> :load A.scala
      Loading A.scala...
      defined class A
      <console>:8: error: too many arguments for method apply: (i: Int)A in object A
               def apply(i: Int): A = A(i, i)
      

      It looks like the lines in the file are loaded and interpreted one by one, which for companion object does not work in the in the REPL. It would be nice if this would work as well.

        Activity

        Hide
        A. P. Marki added a comment -

        In the form `:paste A.scala`
        https://github.com/scala/scala/pull/2696

        Show
        A. P. Marki added a comment - In the form `:paste A.scala` https://github.com/scala/scala/pull/2696
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/2719
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/2725

          People

          • Assignee:
            A. P. Marki
            Reporter:
            arjan blokzijl
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development