Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/ContractConstructor.java
Tagir Valeev 301c703f5d [java-dfa] Check fail result for constructors
GitOrigin-RevId: ce02739377b5d4fc8c2800e6450163bacef80152
2020-11-26 02:54:58 +00:00

17 lines
833 B
Java

import org.jetbrains.annotations.*;
class CandidateInfo<T> {
@Contract("null, true, _ -> fail")
private CandidateInfo(@Nullable Object candidate, boolean applicable, boolean fullySubstituted) {
assert !applicable || candidate != null;
}
static void test() {
if (Math.random() > 0.5) new <warning descr="The call to 'CandidateInfo' always fails, according to its method contracts">CandidateInfo</warning>(null, true, false);
if (Math.random() > 0.5) new <warning descr="The call to 'CandidateInfo' always fails, according to its method contracts">CandidateInfo</warning>(null, true, true);
if (Math.random() > 0.5) new CandidateInfo(null, false, true);
if (Math.random() > 0.5) new CandidateInfo(new Object(), true, true);
if (Math.random() > 0.5) new CandidateInfo(new Object(), false, true);
}
}