Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different treatment for ?: and if...else in dataflow refinement #3622

Closed
mernst opened this issue Sep 4, 2020 · 0 comments · Fixed by #3646
Closed

Different treatment for ?: and if...else in dataflow refinement #3622

mernst opened this issue Sep 4, 2020 · 0 comments · Fixed by #3646

Comments

@mernst
Copy link
Member

mernst commented Sep 4, 2020

Consider the following code. The two classes ImmutableIntList1 and ImmutableIntList2 have the same logic and control flow, but the Nullness Checker issues an error message for the first but not the second:

Issue3622.java:14: error: [contracts.conditional.postcondition.not.satisfied] conditional postcondition is not satisfied when equals returns true.
            return obj instanceof ImmutableIntList1 ? true : obj instanceof List;
            ^
  found   : obj is @Nullable
  required: obj is @NonNull
// Test case for https://tinyurl.com/cfissue/3622

// @skip-test until the issue is fixed

import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;

public class Issue3622 {

    public class ImmutableIntList1 {

        @Override
        public boolean equals(@Nullable Object obj) {
            return obj instanceof ImmutableIntList1 ? true : obj instanceof List;
        }
    }

    public class ImmutableIntList2 {

        @Override
        public boolean equals(@Nullable Object obj) {
            if (obj instanceof ImmutableIntList2) {
                return true;
            } else {
                return obj instanceof List;
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant