Odd behavior invoking thru anonymous class expression

I was writing up a Java-to-Scala example and thought it would be interesting to use an anonymous class expression to support the "fluent interface" pattern, a la

object.someMethod().someOtherMethod()

In Java this is normally done by returning this or a helper class instance from each method. My use case was simpler, I only wanted to chain one method off another, so I wrote this (stripped down from the original code, with debugging added.)

This gives the anonymous instance access to the original add() method scope, which is what I want. When I call it with

val gen = new Gen()
gen.add("a")
gen.add("b").bind("1")

My expectation is that I would get

Adding a
Adding b
Binding 1 to b

Instead the output is

Adding a
Adding b
Adding b
Binding 1 to b

Somehow, gen.add("b") is being called twice. Disassembling the generated class for the unit test shows this is indeed the case.
If I instead use an intermediate val to hold the result of the add method, the behavior is correct:

val c = gen.add("c")
c.bind("2")

yields

Adding c
Binding 2 to c

This is with 2.7.3 RC1 (whatever arrives with the current plugin.)

Have the mysteries of Scala confounded me again or is this genuinely wrong?

Somehow, gen.add("b") is being called twice. Disassembling the generated class for the unit test shows this is indeed the case.
If I instead use an intermediate val to hold the result of the add method, the behavior is correct:

On Wed, Dec 31, 2008 at 5:01 AM, James Iry wrote:
> Looks like a bug to me. Please file it.
>
Yes, this looks like a bug. It seems to be linked to the fact that you
don't declare a superclass that contains the bind method. If you add
such a superclass, it works as expected: