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 256435 - Code auto-completion handles generic wildcards inaccurately
Summary: Code auto-completion handles generic wildcards inaccurately
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 17:14 UTC by tln
Modified: 2015-11-07 17:14 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 17:14:52 UTC
Hi,

NetBeans seems to assume that the wildcard (?) in generic types always represents java.lang.Object, but this isn't correct. That's why some code completion produces unsatisfactory results.

See this example:

public class GenericsBug
{
	public interface SomeInterface<X, XL extends List<X>>
	{
		XL getList();
	}
	
	public static void bug(SomeInterface<Integer, ?> someObject)
	{
		someObject.getList();	// *
	}
}

The cursor is somewhere on the line * and you choose "Assign Return Value To New Variable" from the hints.

The current result is:
Object list=someObject.getList();

The correct (or at least wanted) result would be:
List<Integer> list=someObject.getList();

Having to correct this manually is a little tedious and somehow "ridicules" the usefulness of the feature.
Plus a greater problem is that sometimes when you're dealing with complex generic types it's not obvious at first sight what the correct type would be at all. This can be because you have to look up the generic classes in other files to see what the bounds of the ?s are and it can also be because it's just complex and not easy on the eye. Automatic help by NetBeans would be highly appreciated in these cases.

Thank you.