Skip to content

Commit

Permalink
JSpecify: add another bailout check for raw types (#1021)
Browse files Browse the repository at this point in the history
Fixes #1019
  • Loading branch information
msridhar authored Aug 19, 2024
1 parent ab10020 commit fcd3495
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public Boolean visitClassType(Type.ClassType lhsType, Type rhsType) {
if (rhsTypeAsSuper == null) {
throw new RuntimeException("Did not find supertype of " + rhsType + " matching " + lhsType);
}
// bail out of checking raw types for now
if (rhsTypeAsSuper.isRaw()) {
return true;
}
List<Type> lhsTypeArguments = lhsType.getTypeArguments();
List<Type> rhsTypeArguments = rhsTypeAsSuper.getTypeArguments();
// This is impossible, considering the fact that standard Java subtyping succeeds before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,26 @@ public void issue1014() {
.doTest();
}

@Test
public void issue1019() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.uber;",
"import java.util.ArrayList;",
"import java.util.List;",
"",
"public class Test {",
" public static class StringList extends ArrayList {",
" }",
" @SuppressWarnings(\"unchecked\")",
" public static List<String> convert(final StringList stringList) {",
" return stringList;",
" }",
"}")
.doTest();
}

private CompilationTestHelper makeHelper() {
return makeTestHelperWithArgs(
Arrays.asList(
Expand Down

0 comments on commit fcd3495

Please sign in to comment.