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 256438 - Code completion references class without proper generic types and code won't compile
Summary: Code completion references class without proper generic types and code won't ...
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:23 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:23:22 UTC
Hi,

when referencing an outer class in code completion, NetBeans should respect generics, because if a class is referenced without proper generic types, the code won't compile in many cases.

Example:

public class GenericsBug
{
	public abstract static class A<X>
	{
		public abstract class AInner<Y>
		{
			// these are just examples
			public abstract X getX();
			public abstract Y getY();
		}
		
		public abstract <Y> AInner<Y> makeInner(Y y);
	}
	
	public static class B
	{
		public static void bug(A<Integer> a)
		{
			a.makeInner("Hi");		// *
		}
	}
}

The cursor is on line * and you select "Assign Return Value To New Variable".

Current result:
A.AInner<String> makeInner=a.makeInner("Hi");
This won't compile, because type variable X isn't defined.

Expected result:
A<Integer>.AInner<String> makeInner=a.makeInner("Hi");