@Override public BooleanLiteralSet getPossibleToBooleanOutcomes() { BooleanLiteralSet literals = BooleanLiteralSet.EMPTY; for (int i = 0; i < alternatesRetainingStructuralSubtypes.size(); i++) { JSType element = alternatesRetainingStructuralSubtypes.get(i); literals = literals.union(element.getPossibleToBooleanOutcomes()); if (literals == BooleanLiteralSet.BOTH) { break; } } return literals; }
@Override public BooleanLiteralSet getPossibleToBooleanOutcomes() { BooleanLiteralSet literals = BooleanLiteralSet.EMPTY; for (JSType element : alternatesWithoutStucturalTyping) { literals = literals.union(element.getPossibleToBooleanOutcomes()); if (literals == BooleanLiteralSet.BOTH) { break; } } return literals; }
private static BooleanLiteralSet joinBooleanOutcomes( boolean isAnd, BooleanLiteralSet left, BooleanLiteralSet right) { // A truthy value on the lhs of an {@code &&} can never make it to the // result. Same for a falsy value on the lhs of an {@code ||}. // Hence the intersection. return right.union(left.intersection(BooleanLiteralSet.get(!isAnd))); }
private static BooleanLiteralSet joinBooleanOutcomes( boolean isAnd, BooleanLiteralSet left, BooleanLiteralSet right) { // A truthy value on the lhs of an {@code &&} can never make it to the // result. Same for a falsy value on the lhs of an {@code ||}. // Hence the intersection. return right.union(left.intersection(BooleanLiteralSet.get(!isAnd))); }