Skip to content

Commit fcd3495

Browse files
authored
JSpecify: add another bailout check for raw types (#1021)
Fixes #1019
1 parent ab10020 commit fcd3495

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public Boolean visitClassType(Type.ClassType lhsType, Type rhsType) {
4040
if (rhsTypeAsSuper == null) {
4141
throw new RuntimeException("Did not find supertype of " + rhsType + " matching " + lhsType);
4242
}
43+
// bail out of checking raw types for now
44+
if (rhsTypeAsSuper.isRaw()) {
45+
return true;
46+
}
4347
List<Type> lhsTypeArguments = lhsType.getTypeArguments();
4448
List<Type> rhsTypeArguments = rhsTypeAsSuper.getTypeArguments();
4549
// This is impossible, considering the fact that standard Java subtyping succeeds before

nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,26 @@ public void issue1014() {
19281928
.doTest();
19291929
}
19301930

1931+
@Test
1932+
public void issue1019() {
1933+
makeHelper()
1934+
.addSourceLines(
1935+
"Test.java",
1936+
"package com.uber;",
1937+
"import java.util.ArrayList;",
1938+
"import java.util.List;",
1939+
"",
1940+
"public class Test {",
1941+
" public static class StringList extends ArrayList {",
1942+
" }",
1943+
" @SuppressWarnings(\"unchecked\")",
1944+
" public static List<String> convert(final StringList stringList) {",
1945+
" return stringList;",
1946+
" }",
1947+
"}")
1948+
.doTest();
1949+
}
1950+
19311951
private CompilationTestHelper makeHelper() {
19321952
return makeTestHelperWithArgs(
19331953
Arrays.asList(

0 commit comments

Comments
 (0)