adriaanm/scala-dev — Issue #9: Dynamic semantics (to support updates)
Author: namin
Created: 2011-10-11 11:26:38+00:00
State: open

As discussed, if `x` is Dynamic with unresolved field `foo`, we want:
`x.foo` to transform to `x.selectDynamic("foo")`
`x.foo(a, b, c)` to transform to `x.selectDynamic("foo").apply(a, b, c)` (instead of `x.applyDynamic("foo")(a, b, c)` currently)
`x.foo = 3` to transform to `x.selectDynamic("foo").update(3)` -- This should work even if `foo` has no parenthesis after it. See the note below.
`x.foo(2) = 3` to transform to `x.selectDynamic("foo").update(2, 3)`

Note that currently, updates with no index argument only work if empty parenthesis are provided. Otherwise, we get a 'reassignment to a val' error. See the transcript below.

```
scala> class A { def update(x: Int) = print("update " + 1) }
defined class A

scala> val a = new A
a: A = A@90564f7

scala> a = 2
:9: error: reassignment to val
a = 2
^

scala> a() = 2
update 1
scala> val b = new { val a = new A }
b: java.lang.Object{val a: A} = $anon$1@384f14b0

scala> b.a = 2
:9: error: reassignment to val
b.a = 2
^

scala> b.a() = 2
update 1
scala> b.a = 2
:9: error: reassignment to val
b.a = 2
^

scala> b.a() = 2
update 1
```