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 233129 - "Use diamond inference" ("Can Use Diamond") hint may lead to incompatible types error
Summary: "Use diamond inference" ("Can Use Diamond") hint may lead to incompatible typ...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-22 05:00 UTC by xehpuk
Modified: 2013-08-21 02:46 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 xehpuk 2013-07-22 05:00:03 UTC
Product Version = NetBeans IDE Dev (Build 201307202300)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.8.0-ea
Runtime = Java HotSpot(TM) Client VM 25.0-b41

Before:
import java.util.*;
class Test<T> {
	static void test() {
		Number s = new Test<Number>().first(Arrays.asList(0)); // Hint: "Use diamond inference"
	}

	T first(List<T> t) {
		return t.get(0);
	}
}

After:
import java.util.*;
class Test<T> {
	static void test() {
		Number s = new Test<>().first(Arrays.asList(0)); // Error: "incompatible types: Object cannot be converted to Number"
	}

	T first(List<T> t) {
		return t.get(0);
	}
}

Same for "T first(List<? extends T> t)".
Works correctly for "<U extends T> U first(List<U> u)".

So in the first two cases the hint should not be shown since the compiler needs this type information.
Comment 1 Jan Lahoda 2013-08-20 12:01:44 UTC
Fixed:
http://hg.netbeans.org/jet-main/rev/3dcdd113c5bb
Comment 2 Quality Engineering 2013-08-21 02:46:30 UTC
Integrated into 'main-silver', will be available in build *201308202300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/3dcdd113c5bb
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #158491&#233129&#234572&#229157(partial): incorporating updated nb-javac