From 036078136a64a487e400e0ef77038568534e082b Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Sun, 26 Nov 2023 18:10:46 -0500 Subject: [PATCH 1/2] Do not use `thisValue` when it is the NullType --- .../initialization/InitializationStore.java | 4 +++- .../EisopIssue635.java | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 checker/tests/nullness-initialization/EisopIssue635.java 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(); + } + }; + } +} From a87a950e9a285bafea23053941b3411a1d005ab1 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Sun, 26 Nov 2023 18:18:05 -0500 Subject: [PATCH 2/2] Add changelog entry --- docs/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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) -----------------------------------------