use of com.google.javascript.rhino.jstype.JSType.TypePair in project closure-compiler by google.
the class SemanticReverseAbstractInterpreter method caseEquality.
@CheckReturnValue
private FlowScope caseEquality(Node left, Node right, FlowScope blindScope, Function<TypePair, TypePair> merging) {
// left type
JSType leftType = getTypeIfRefinable(left, blindScope);
boolean leftIsRefineable;
if (leftType != null) {
leftIsRefineable = true;
} else {
leftIsRefineable = false;
leftType = left.getJSType();
}
// right type
JSType rightType = getTypeIfRefinable(right, blindScope);
boolean rightIsRefineable;
if (rightType != null) {
rightIsRefineable = true;
} else {
rightIsRefineable = false;
rightType = right.getJSType();
}
// merged types
TypePair merged = merging.apply(new TypePair(leftType, rightType));
// creating new scope
if (merged != null) {
return maybeRestrictTwoNames(blindScope, left, leftType, leftIsRefineable ? merged.typeA : null, right, rightType, rightIsRefineable ? merged.typeB : null);
}
return blindScope;
}
use of com.google.javascript.rhino.jstype.JSType.TypePair in project closure-compiler by google.
the class JSTypeTest method testGetTypeUnderEquality.
private void testGetTypeUnderEquality(JSType t1, JSType t2, JSType t1Eq, JSType t2Eq) {
// creating the pairs
TypePair p12 = t1.getTypesUnderEquality(t2);
TypePair p21 = t2.getTypesUnderEquality(t1);
// t1Eq
assertTypeEquals(t1Eq, p12.typeA);
assertTypeEquals(t1Eq, p21.typeB);
// t2Eq
assertTypeEquals(t2Eq, p12.typeB);
assertTypeEquals(t2Eq, p21.typeA);
}
use of com.google.javascript.rhino.jstype.JSType.TypePair in project closure-compiler by google.
the class JSTypeTest method testGetTypesUnderInequality.
private void testGetTypesUnderInequality(JSType t1, JSType t2, JSType t1Eq, JSType t2Eq) {
// creating the pairs
TypePair p12 = t1.getTypesUnderInequality(t2);
TypePair p21 = t2.getTypesUnderInequality(t1);
// t1Eq
assertTypeEquals(t1Eq, p12.typeA);
assertTypeEquals(t1Eq, p21.typeB);
// t2Eq
assertTypeEquals(t2Eq, p12.typeB);
assertTypeEquals(t2Eq, p21.typeA);
}
Aggregations