-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c2bf68
commit 8ef64a8
Showing
5 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
java/ql/test/query-tests/UselessTypeTest/UselessTypeTest.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
| UselessTypeTest.java:11:9:11:28 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String | String | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String | String | | ||
| UselessTypeTest.java:12:9:12:28 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String | String | file:///modules/java.base/java/lang/Object.class:0:0:0:0 | Object | Object | | ||
| UselessTypeTest.java:13:9:13:60 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | | ||
| UselessTypeTest.java:14:9:14:55 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<?> | ArrayList<?> | | ||
| UselessTypeTest.java:15:9:15:68 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<? super String> | ArrayList<? super String> | | ||
| UselessTypeTest.java:16:9:16:70 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<? extends String> | ArrayList<? extends String> | | ||
| UselessTypeTest.java:17:9:17:63 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<? super String> | List<? super String> | | ||
| UselessTypeTest.java:18:9:18:65 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<? extends String> | List<? extends String> | | ||
| UselessTypeTest.java:19:9:19:44 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<?> | ArrayList<?> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:20:9:20:60 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<? super String> | ArrayList<? super String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<?> | List<?> | | ||
| UselessTypeTest.java:21:9:21:57 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<? super String> | ArrayList<? super String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:22:9:22:62 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<? extends String> | ArrayList<? extends String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<?> | List<?> | | ||
| UselessTypeTest.java:23:9:23:59 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<? extends String> | ArrayList<? extends String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:24:9:24:39 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<?> | List<?> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:25:9:25:55 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<? super String> | List<? super String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<?> | List<?> | | ||
| UselessTypeTest.java:26:9:26:52 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<? super String> | List<? super String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:27:9:27:57 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<? extends String> | List<? extends String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<?> | List<?> | | ||
| UselessTypeTest.java:28:9:28:54 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<? extends String> | List<? extends String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:29:9:29:52 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<> | ArrayList<> | | ||
| UselessTypeTest.java:30:9:30:47 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<> | ArrayList<> | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<?> | ArrayList<?> | | ||
| UselessTypeTest.java:31:9:31:55 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<String> | List<String> | | ||
| UselessTypeTest.java:32:9:32:50 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<?> | List<?> | | ||
| UselessTypeTest.java:33:9:33:47 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<String> | ArrayList<String> | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<> | List<> | | ||
| UselessTypeTest.java:34:9:34:47 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | UselessTypeTest.java:6:18:6:29 | ExtendingRaw | ExtendingRaw | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<> | ArrayList<> | | ||
| UselessTypeTest.java:35:9:35:50 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | UselessTypeTest.java:6:18:6:29 | ExtendingRaw | ExtendingRaw | file:///modules/java.base/java/util/ArrayList.class:0:0:0:0 | ArrayList<?> | ArrayList<?> | | ||
| UselessTypeTest.java:36:9:36:41 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file://:0:0:0:0 | String[] | String[] | file://:0:0:0:0 | String[] | String[] | | ||
| UselessTypeTest.java:37:9:37:39 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file://:0:0:0:0 | String[] | String[] | file:///modules/java.base/java/lang/Object.class:0:0:0:0 | Object | Object | | ||
| UselessTypeTest.java:38:9:38:41 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file://:0:0:0:0 | String[] | String[] | file://:0:0:0:0 | Object[] | Object[] | | ||
| UselessTypeTest.java:39:9:39:36 | ...instanceof... | There is no need to test whether an instance of $@ is also an instance of $@ - it always is. | file://:0:0:0:0 | int[] | int[] | file:///modules/java.base/java/lang/Object.class:0:0:0:0 | Object | Object | |
52 changes: 52 additions & 0 deletions
52
java/ql/test/query-tests/UselessTypeTest/UselessTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
class UselessTypeTest { | ||
static class ExtendingRaw extends ArrayList { | ||
} | ||
|
||
Object obj = null; | ||
boolean[] bad = { | ||
"" instanceof String, | ||
"" instanceof Object, | ||
new ArrayList<String>() instanceof ArrayList<String>, | ||
new ArrayList<String>() instanceof ArrayList<?>, | ||
new ArrayList<String>() instanceof ArrayList<? super String>, | ||
new ArrayList<String>() instanceof ArrayList<? extends String>, | ||
new ArrayList<String>() instanceof List<? super String>, | ||
new ArrayList<String>() instanceof List<? extends String>, | ||
((ArrayList<?>) obj) instanceof List, | ||
((ArrayList<? super String>) obj) instanceof List<?>, | ||
((ArrayList<? super String>) obj) instanceof List, | ||
((ArrayList<? extends String>) obj) instanceof List<?>, | ||
((ArrayList<? extends String>) obj) instanceof List, | ||
((List<?>) obj) instanceof List, | ||
((List<? super String>) obj) instanceof List<?>, | ||
((List<? super String>) obj) instanceof List, | ||
((List<? extends String>) obj) instanceof List<?>, | ||
((List<? extends String>) obj) instanceof List, | ||
new ArrayList<String>() instanceof ArrayList, | ||
new ArrayList() instanceof ArrayList<?>, | ||
new ArrayList<String>() instanceof List<String>, | ||
new ArrayList<String>() instanceof List<?>, | ||
new ArrayList<String>() instanceof List, | ||
new ExtendingRaw() instanceof ArrayList, | ||
new ExtendingRaw() instanceof ArrayList<?>, | ||
new String[0] instanceof String[], | ||
new String[0] instanceof Object, | ||
new String[0] instanceof Object[], | ||
new int[0] instanceof Object, | ||
}; | ||
|
||
boolean[] good = { | ||
new Object() instanceof Number, | ||
new ArrayList<String>() instanceof Map<?, ?>, | ||
new ArrayList<String>() instanceof Map, | ||
((List<? super String>) obj) instanceof ArrayList<?>, | ||
((List<? super String>) obj) instanceof ArrayList<? super String>, | ||
new Object() instanceof int[], | ||
new Object() instanceof Object[], | ||
new Object[0] instanceof String[], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Language Abuse/UselessTypeTest.ql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//semmle-extractor-options: --javac-args --enable-preview -source 15 -target 15 |