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.
The "assign result value to a new variable" hint sometimes does not produce the correct type for the variable, consider: --- import java.util.Map; public class InferTest { void test(Map<? extends String, ? extends Number> map) { map.entrySet();//assign return value to a new variable here } } --- The "assign return value to a new variable" will produce: --- Set<Entry<? extends String, ? extends Number>> entrySet = map.entrySet(); --- Which won't compile: --- InferTest.java:7: error: incompatible types: Set<Entry<CAP#1,CAP#2>> cannot be converted to Set<Entry<? extends String,? extends Number>> Set<Entry<? extends String, ? extends Number>> entrySet = map.entrySet(); //assign return value to a new variable here where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends String from capture of ? extends String CAP#2 extends Number from capture of ? extends Number 1 error --- Inferring this would be more appropriate: --- Set<? extends Entry<? extends String, ? extends Number>> entrySet = map.entrySet(); --- This is on: NetBeans IDE 8.1 RC2 (Build 20151012-f7fbd7b7b85b) (Reported by Stuart Marks.)
*** Bug 171272 has been marked as a duplicate of this bug. ***
*** Bug 170574 has been marked as a duplicate of this bug. ***
Fixed in jet-main#15fde243019c
Integrated into 'main-silver', will be available in build *201606180002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/15fde243019c User: Svata Dedic <sdedic@netbeans.org> Log: #258167: infer declared variable type from the expression