Java Code Examples for com.google.javascript.rhino.jstype.JSType#canTestForShallowEqualityWith()

The following examples show how to use com.google.javascript.rhino.jstype.JSType#canTestForShallowEqualityWith() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Closure_117_TypeValidator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the type of a switch condition matches the type of its
 * case condition.
 */
void expectSwitchMatchesCase(NodeTraversal t, Node n, JSType switchType,
    JSType caseType) {
  // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
  // but allowing extra autoboxing.
  // TODO(user): remove extra conditions when type annotations
  // in the code base have adapted to the change in the compiler.
  if (!switchType.canTestForShallowEqualityWith(caseType) &&
      (caseType.autoboxesTo() == null ||
          !caseType.autoboxesTo().isSubtype(switchType))) {
    mismatch(t, n.getFirstChild(),
        "case expression doesn't match switch",
        caseType, switchType);
  }
}
 
Example 2
Source File: Closure_117_TypeValidator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the type of a switch condition matches the type of its
 * case condition.
 */
void expectSwitchMatchesCase(NodeTraversal t, Node n, JSType switchType,
    JSType caseType) {
  // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
  // but allowing extra autoboxing.
  // TODO(user): remove extra conditions when type annotations
  // in the code base have adapted to the change in the compiler.
  if (!switchType.canTestForShallowEqualityWith(caseType) &&
      (caseType.autoboxesTo() == null ||
          !caseType.autoboxesTo().isSubtype(switchType))) {
    mismatch(t, n.getFirstChild(),
        "case expression doesn't match switch",
        caseType, switchType);
  }
}
 
Example 3
Source File: Closure_6_TypeValidator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the type of a switch condition matches the type of its
 * case condition.
 */
void expectSwitchMatchesCase(NodeTraversal t, Node n, JSType switchType,
    JSType caseType) {
  // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
  // but allowing extra autoboxing.
  // TODO(user): remove extra conditions when type annotations
  // in the code base have adapted to the change in the compiler.
  if (!switchType.canTestForShallowEqualityWith(caseType) &&
      (caseType.autoboxesTo() == null ||
          !caseType.autoboxesTo().isSubtype(switchType))) {
    mismatch(t, n.getFirstChild(),
        "case expression doesn't match switch",
        caseType, switchType);
  }
}
 
Example 4
Source File: Closure_6_TypeValidator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the type of a switch condition matches the type of its
 * case condition.
 */
void expectSwitchMatchesCase(NodeTraversal t, Node n, JSType switchType,
    JSType caseType) {
  // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
  // but allowing extra autoboxing.
  // TODO(user): remove extra conditions when type annotations
  // in the code base have adapted to the change in the compiler.
  if (!switchType.canTestForShallowEqualityWith(caseType) &&
      (caseType.autoboxesTo() == null ||
          !caseType.autoboxesTo().isSubtype(switchType))) {
    mismatch(t, n.getFirstChild(),
        "case expression doesn't match switch",
        caseType, switchType);
  }
}
 
Example 5
Source File: TypeValidator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expect that the type of a switch condition matches the type of its
 * case condition.
 */
void expectSwitchMatchesCase(NodeTraversal t, Node n, JSType switchType,
    JSType caseType) {
  // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
  // but allowing extra autoboxing.
  // TODO(user): remove extra conditions when type annotations
  // in the code base have adapted to the change in the compiler.
  if (!switchType.canTestForShallowEqualityWith(caseType) &&
      (caseType.autoboxesTo() == null ||
          !caseType.autoboxesTo().isSubtype(switchType))) {
    mismatch(t, n.getFirstChild(),
        "case expression doesn't match switch",
        caseType, switchType);
  }
}