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

calling setter method on result of Map.apply causes an error

    Details

      Description

      If one tries to update a value in a Map by calling its corresponding setter, the REPL throws an error:

      scala> case class X(var x: Int)
      defined class X
      
      scala> val m = Map('x -> X(1))
      m: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(1))
      
      scala> m('x).x = 7
      <console>:10: error: ')' expected but string literal found.
       + "m(scala.Symbol("x")).x: Int = " + `$ires0` + "\n" 
                          ^
      

      This error occurs both in a nightly version of 2.10 and in 2.9.2, but in the latter no error message is thrown. Using an explicitly typed setter, no error occurs:

      scala> m('x).x_=(7)
      
      scala> m
      res1: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(7))
      

      Furthermore, this error occurs only inside of the REPL, not by compiling/interpreting of a Scala source file.

        Activity

        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/1699

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Simon Schäfer
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development