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 - Code completion creates code with generic inner classes that won't compile because of static context
Summary: Code completion creates code with generic inner classes that won't compile be...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-07 18:14 UTC by tln
Modified: 2015-11-07 18:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.