Skip to content

Commit

Permalink
Fix crash with annotation on enum (#1097)
Browse files Browse the repository at this point in the history
Fixes #1093 

We just missed a case.
  • Loading branch information
msridhar authored Dec 17, 2024
1 parent cb3ff51 commit 346b9b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nullaway/src/main/java/com/uber/nullaway/NullabilityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ private static boolean targetTypeMatches(Symbol sym, TypeAnnotationPosition posi
return false;
}
case CLASS:
// There are no type annotations on the top-level type of the class being declared, only
// on other types in the signature (e.g. `class Foo extends Bar<@A Baz> {}`).
// treated like a class
case ENUM:
// There are no type annotations on the top-level type of the class/enum being declared,
// only on other types in the signature (e.g. `class Foo extends Bar<@A Baz> {}`).
return false;
default:
// Compare with toString() to preserve compatibility with JDK 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,24 @@ public void issue1082() {
.doTest();
}

@Test
public void issue1093() {
makeHelper()
.addSourceLines(
"Main.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"public class Main {",
" interface CacheLoader<V extends @Nullable Object> {",
" }",
" enum Loader implements CacheLoader<@Nullable Integer> {",
" NULL;",
" Loader() {}",
" }",
"}")
.doTest();
}

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

0 comments on commit 346b9b0

Please sign in to comment.