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.
Example: <K, V> void f(Map<? extends K, ? extends V> map) { map.entrySet(); } "Assign Return Value To New Variable" results in: <K, V> void f(Map<? extends K, ? extends V> map) { Set<Entry<? extends K, ? extends V>> entrySet = map.entrySet(); } This doesn't compile (unfortunately). What would compile is: <K, V> void f(Map<? extends K, ? extends V> map) { Set<? extends Entry<? extends K, ? extends V>> entrySet = map.entrySet(); }
PS: The reason it doesn't compile is that if it would, then this <K, V> void f(Map<? extends K, ? extends V> map, Entry<? extends K, ? extends V> entry) { Set<Entry<? extends K, ? extends V>> entrySet = map.entrySet(); entrySet.add(entry); } void g() { Map<String, String> strMap = ...; Map<Number, Number> numMap = ...; f(strMap, numMap.entrySet().iterator().next()); } would compile too (where K = V = Object), allowing to add any type of entry to any type of map. (Yes, map.entrySet() doesn't actually support add(), but let's assume it did.) So, this is not a compiler bug.
Still reproducable in 6.8 Beta.
*** This bug has been marked as a duplicate of bug 258167 ***