File tree 2 files changed +21
-1
lines changed
main/java/com/uber/nullaway
test/java/com/uber/nullaway/jspecify
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 22
22
23
23
package com .uber .nullaway ;
24
24
25
+ import static com .uber .nullaway .ASTHelpersBackports .hasDirectAnnotationWithSimpleName ;
25
26
import static com .uber .nullaway .ASTHelpersBackports .isStatic ;
26
27
import static com .uber .nullaway .ErrorMessage .MessageTypes .FIELD_NO_INIT ;
27
28
import static com .uber .nullaway .ErrorMessage .MessageTypes .GET_ON_EMPTY_OPTIONAL ;
@@ -415,7 +416,9 @@ void reportInitializerError(
415
416
// Check needed here, despite check in hasPathSuppression because initialization
416
417
// checking happens at the class-level (meaning state.getPath() might not include the
417
418
// method itself).
418
- if (symbolHasSuppressWarningsAnnotation (methodSymbol , INITIALIZATION_CHECK_NAME )) {
419
+ if (symbolHasSuppressWarningsAnnotation (methodSymbol , INITIALIZATION_CHECK_NAME )
420
+ || hasDirectAnnotationWithSimpleName (
421
+ methodSymbol , NullabilityUtil .NULLUNMARKED_SIMPLE_NAME )) {
419
422
return ;
420
423
}
421
424
Tree methodTree = getTreesInstance (state ).getTree (methodSymbol );
Original file line number Diff line number Diff line change @@ -1156,4 +1156,21 @@ public void dotClassSanityTest2() {
1156
1156
"}" )
1157
1157
.doTest ();
1158
1158
}
1159
+
1160
+ @ Test
1161
+ public void nullUnmarkedOnConstructorSuppressesInitializerWarnings () {
1162
+ defaultCompilationHelper
1163
+ .addSourceLines (
1164
+ "Foo.java" ,
1165
+ "package com.uber;" ,
1166
+ "import org.jspecify.annotations.NullUnmarked;" ,
1167
+ "import org.jspecify.annotations.Nullable;" ,
1168
+ "public class Foo {" ,
1169
+ " public Object f;" ,
1170
+ " @NullUnmarked" ,
1171
+ " // No error, because Foo is unmarked" ,
1172
+ " public Foo() { }" ,
1173
+ "}" )
1174
+ .doTest ();
1175
+ }
1159
1176
}
You can’t perform that action at this time.
0 commit comments