Community
Participate
Working Groups
The semantics will be just like in Java, the syntax is almost the same. The single difference is that instead of repetition of the class' name you only need to write the keyword 'constructor'. This reduces redundancy and at the same time gives a nice visual anchor in the text file. Example: class MyClass extends AnotherClass { constructor () { this("MyClass") } constructor (String name) { super(name) } }
In Xbase everything is an expression but might compile to a sequence of Java statements. Java does only allow expressions that don't call non-static methods in the constructor's arguments. We have to specify/verify what kind of Xbase expressions are allowed as arguments in Xtend's super/this calls.
My idea was to allow all the expressions and as long as we can't turn it into a Java expression, we generate something like: super(new Function0<String>() { public String apply() { // generated Java statements. } }.apply()); In addition we should add a compiler check for this context so invalid calls get marked. Btw.: we should do the same thing for field initializers.
To be done: Validation for super(..) call / this(..) call Cyclic constructor invocation Expressify the arguments that are passed to super(..) / this(..) Compiler Current syntax proposal: class Z extends Something { new(int a, int b) { super(a + b) } }
Pushed working version. Remaining issues will be tracked in own tickets.
Closing all bugs that were set to RESOLVED before Neon.0