'improperly formed type' error

Mark Mahieu mark at twistedbanana.demon.co.uk
Fri Jun 20 02:06:48 PDT 2008


This one's a minor niggle - a non-static generic inner class nested  
in another generic class cannot be instantiated from within a closure  
unless qualified with the enclosing type:


class ImproperlyFormedType<E> {
	
	class Inner<T> {}

	void makeInner() {
		
		// this is ok
		new Inner<String>();
		
		// but not when wrapped in a closure
		{=> new Inner<String>(); }.invoke();
		
		// qualifying it solves the problem
		{=> new ImproperlyFormedType<E>.Inner<String>(); }.invoke();
	}
}


ImproperlyFormedType.java:11: improperly formed type, type parameters  
given on a raw type
                 {=> new Inner<String>(); }.invoke();
                              ^
1 error


Regards,

Mark



More information about the closures-dev mailing list