scalagen icon indicating copy to clipboard operation
scalagen copied to clipboard

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

Open erikkaplun opened this issue 10 years ago • 0 comments

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.

erikkaplun avatar Nov 20 '13 19:11 erikkaplun