timowest / scalagen

Java to Scala transformation
Apache License 2.0
216 stars 32 forks source link

Matching constructor parameter name and member variable name leads to invalid code #72

Open erikkaplun opened 10 years ago

erikkaplun commented 10 years ago

this:

class Foo {
    private int bar;
    public Foo(int bar) {
        this.bar = bar * 2; // ok in Java
    }
}

gets converted to:

class Foo(bar: Int) {
    private val bar = bar * 2 // compiler complains that recursive val requires type
}

Should be handled for example by prefixing the member variable with _ perhaps; or the other way around, especially when the member variable is public and naming matters.