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.
ACTUAL: no hint, code is compilable - for example <code> public <T extends String> T foo(){ return null; } public Collection<? extends String> bar(){ return null; } public void doBla(){ List<? extends String> arrayListA = new ArrayList<String>(); List<? extends Integer> arrayListB = new ArrayList<Integer>(); } </code> EXPECTED: Provide hints to remove the unnecessary wildcard types. It is not possible to subclass final classes (f.e. String, Integer) - transformed example <code> public String foo(){ return null; } public Collection<String> bar(){ return null; } public void doBla(){ List<String> arrayListA = new ArrayList<String>(); List<Integer> arrayListB = new ArrayList<Integer>(); } </code>
Sorry, but no. The semantics of List<? extends String> is very different from List<String>: the first is "read-only", the latter is read-write. Compare e.g.: List<? extends String> l1 = null; List<String> l2 = null; l1.add(""); //compilation error l2.add(""); //OK So using ? extends FinalType may generally be (and often is - otherwise, why the extra characters were typed?) intentional, and is generally neither safe not good to remove.
(In reply to comment #1) > Sorry, but no. > > The semantics of List<? extends String> is very different from List<String>: > the first is "read-only", the latter is read-write. Compare e.g.: > List<? extends String> l1 = null; > List<String> l2 = null; > > l1.add(""); //compilation error > l2.add(""); //OK > > So using ? extends FinalType may generally be (and often is - otherwise, why > the extra characters were typed?) intentional, and is generally neither safe > not good to remove. You are right. Thanks for the clarification.