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.
Summary: | [68cat] "Assign Return Value To New Variable" infers wildcard bounds that don't compile | ||
---|---|---|---|
Product: | java | Reporter: | matthies <matthies> |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED DUPLICATE | ||
Severity: | blocker | ||
Priority: | P4 | ||
Version: | 6.x | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 262073 | ||
Bug Blocks: |
Description
matthies
2009-09-01 16:50:13 UTC
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 *** |