Skip to content

Commit

Permalink
Do not use thisValue when it is the NullType (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl authored Nov 27, 2023
1 parent 4f53c5b commit 3c4dad3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions checker/tests/nullness-initialization/EisopIssue635.java
Original file line number Diff line number Diff line change
@@ -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();
}
};
}
}
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Version 3.40.0-eisop3 (November ??, 2023)

**Closed issues:**

eisop#635.


Version 3.40.0-eisop2 (November 24, 2023)
-----------------------------------------
Expand Down

0 comments on commit 3c4dad3

Please sign in to comment.