Bug 418425 - Disallow references to 'this' and 'super' within super() or this() calls within a constructor
Summary: Disallow references to 'this' and 'super' within super() or this() calls with...
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.5.1   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-01 09:54 EDT by Christian Vogel CLA
Modified: 2013-12-20 05:52 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Vogel CLA 2013-10-01 09:54:42 EDT
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.
Comment 1 Christian Vogel CLA 2013-10-01 10:01:14 EDT
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.