You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a sub-issue of #5969 (where it is described as false positive 1). Consider the following code, which I've checked into the cm-ownership-transfer-at-reassignment branch of my fork:
import org.checkerframework.checker.calledmethods.qual.EnsuresCalledMethods;
import org.checkerframework.checker.mustcall.qual.CreatesMustCallFor;
import org.checkerframework.checker.mustcall.qual.InheritableMustCall;
import org.checkerframework.checker.mustcall.qual.Owning;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.io.IOException;
@InheritableMustCall("disconnect")
public class OwnershipTransferAtReassignment {
private @Owning @Nullable Node head = null;
@CreatesMustCallFor("this")
public boolean add() {
head = new Node(head);
return true;
}
@EnsuresCalledMethods(value="this.head", methods="disconnect")
public void disconnect() {
head.disconnect();
}
@InheritableMustCall("disconnect")
private static class Node {
@Owning private final @Nullable Node next;
public Node(@Owning @Nullable Node next) {
this.next = next;
}
@EnsuresCalledMethods(value="this.next", methods="disconnect")
public void disconnect() {
next.disconnect();
}
}
}
Currently, the checker issues a warning when head is re-assigned at line 16. No warnings should be issued (the re-assignment is safe, because ownership is transferred during the re-assignment to the Node constructor).
The text was updated successfully, but these errors were encountered:
This is a sub-issue of #5969 (where it is described as false positive 1). Consider the following code, which I've checked into the
cm-ownership-transfer-at-reassignment
branch of my fork:Currently, the checker issues a warning when
head
is re-assigned at line 16. No warnings should be issued (the re-assignment is safe, because ownership is transferred during the re-assignment to theNode
constructor).The text was updated successfully, but these errors were encountered: