This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 256437

Summary: Code completion creates code with generic inner classes that won't compile because of static context
Product: java Reporter: tln
Component: EditorAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Windows 7   
See Also: https://netbeans.org/bugzilla/show_bug.cgi?id=256438
Issue Type: DEFECT Exception Reporter:

Description tln 2015-11-07 18:14:25 UTC
Hi,

sometimes the outer class context can't be relied upon from a static context when generics are involved. NetBeans currently doesn't respect this.

See this example:

public abstract class GenericsBug<X>
{
	public abstract class Inner<Y>
	{
		// these two methods are just here to demonstrate that
		// both X and Y are available here and need to be resolved
		// by the compiler
		public abstract X getX();
		public abstract Y getY();
	}
	
	public abstract <Y> Inner<Y> makeInner(Y y);
	
	public static void bug(GenericsBug<Integer> object)
	{
		object.makeInner("Hi");			// *
	}
}

On the line * you ask for "Assign Return Value To New Variable".

Current result:
Inner<String> makeInner=object.makeInner("Hi");
This doesn't compile, because the object makeInner doesn't have X type variable resolved.

Expected result:
GenericsBug<Integer>.Inner<String> makeInner=object.makeInner("Hi");

This will compile.