Community
Participate
Working Groups
I am using RXJava, and the following code gives no error in Xtend: import rx.Observable import rx.Observer import rx.Subscription import rx.Observable.OnSubscribeFunc class ListeningObserver<T> extends Observable<T> { var (T)=>void listener new() { super [ Observer<? super T> o | listener = [ if(it == null) o.onCompleted else o.onNext(it) ] [|] as Subscription ] } protected new(OnSubscribeFunc<T> onSubscribe) { super(onSubscribe) } def (T)=>void getListener() { listener } } Note that the super call tries to call the protected new method below it. I have tried rewriting the [|] as Subscription part with a separate class but that had no effect, so I suspect it is the super call with a delta that causes the problem. The tricky part is that once the new() method is added, xtend gives no errors and the java source file simply disappears (no errors). So there is no way (that I know) to figure out what is actually going wrong. Removing the new() function makes the Java source file reappear again.
While implementing in Java, I figured out why the code will not work. I cannot refer to an instance variable within a constructor. Duh :-) The bug stands though.