Skip to content

Commit d525bdb

Browse files
Resolve new "unnecessary @SuppressWarnings" with new test as a witness
1 parent a6fcc91 commit d525bdb

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,33 @@ static class ChildTwo extends ParentGeneric<Integer> {}
21402140
"""});
21412141
}
21422142

2143+
public void testListRewrite() {
2144+
// previously this triggered an unchecked warning
2145+
runNegativeTest(new String[] {
2146+
"X.java",
2147+
"""
2148+
import java.util.*;
2149+
public class X {
2150+
public List getOriginalList(List list) {
2151+
return Collections.unmodifiableList(list);
2152+
}
2153+
}
2154+
"""
2155+
},
2156+
"""
2157+
----------
2158+
1. WARNING in X.java (at line 3)
2159+
public List getOriginalList(List list) {
2160+
^^^^
2161+
List is a raw type. References to generic type List<E> should be parameterized
2162+
----------
2163+
2. WARNING in X.java (at line 3)
2164+
public List getOriginalList(List list) {
2165+
^^^^
2166+
List is a raw type. References to generic type List<E> should be parameterized
2167+
----------
2168+
""");
2169+
}
21432170
public static Class<GenericsRegressionTest_9> testClass() {
21442171
return GenericsRegressionTest_9.class;
21452172
}

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ListRewrite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @see ASTRewrite#getListRewrite(ASTNode, ChildListPropertyDescriptor)
3737
* @since 3.0
3838
*/
39-
@SuppressWarnings({"rawtypes", "unchecked"})
39+
@SuppressWarnings("rawtypes")
4040
public final class ListRewrite {
4141

4242
private final ASTNode parent;

0 commit comments

Comments
 (0)