diff --git a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationStore.java b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationStore.java index a40ceb3aba0..34b60a09ad0 100644 --- a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationStore.java +++ b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationStore.java @@ -158,7 +158,9 @@ protected boolean isDeclaredInitialized(FieldAccess fieldAccess) { InitializationParentAnnotatedTypeFactory atypeFactory = (InitializationParentAnnotatedTypeFactory) analysis.getTypeFactory(); AnnotatedTypeMirror receiverType; - if (thisValue != null && thisValue.getUnderlyingType().getKind() != TypeKind.ERROR) { + if (thisValue != null + && thisValue.getUnderlyingType().getKind() != TypeKind.ERROR + && thisValue.getUnderlyingType().getKind() != TypeKind.NULL) { receiverType = AnnotatedTypeMirror.createType( thisValue.getUnderlyingType(), atypeFactory, false); diff --git a/checker/tests/nullness-initialization/EisopIssue635.java b/checker/tests/nullness-initialization/EisopIssue635.java new file mode 100644 index 00000000000..d8416628d57 --- /dev/null +++ b/checker/tests/nullness-initialization/EisopIssue635.java @@ -0,0 +1,22 @@ +import org.checkerframework.checker.nullness.qual.Nullable; + +class EisopIssue635 { + + private @Nullable Runnable r; + + private void f() { + // No crash without this assignment first. + r = null; + r = + new Runnable() { + @Override + public void run() { + if (r != this) { + return; + } + // No crash without this call. + f(); + } + }; + } +} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2d71038049d..6e9f0d4a6a2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,8 @@ Version 3.40.0-eisop3 (November ??, 2023) **Closed issues:** +eisop#635. + Version 3.40.0-eisop2 (November 24, 2023) -----------------------------------------