import org.jetbrains.annotations.*; class CandidateInfo { @Contract("null, true, _ -> fail") private CandidateInfo(@Nullable Object candidate, boolean applicable, boolean fullySubstituted) { assert !applicable || candidate != null; } static void test() { new CandidateInfo(null, true, false); new CandidateInfo(null, true, true); new CandidateInfo(null, false, true); new CandidateInfo(new Object(), true, true); new CandidateInfo(new Object(), false, true); } }