Java Code Examples for com.google.javascript.rhino.jstype.FunctionType#hasCachedValues()

The following examples show how to use com.google.javascript.rhino.jstype.FunctionType#hasCachedValues() . 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_6_TypeValidator_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 2
Source File: Closure_6_TypeValidator_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 3
Source File: TypeValidator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 4
Source File: Closure_117_TypeValidator_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null && declaredSuper.isTemplatizedType()) {
    declaredSuper =
        declaredSuper.toMaybeTemplatizedType().getReferencedType();
  }
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}
 
Example 5
Source File: Closure_117_TypeValidator_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Expect that the first type is the direct superclass of the second type.
 *
 * @param t The node traversal.
 * @param n The node where warnings should point to.
 * @param superObject The expected super instance type.
 * @param subObject The sub instance type.
 */
void expectSuperType(NodeTraversal t, Node n, ObjectType superObject,
    ObjectType subObject) {
  FunctionType subCtor = subObject.getConstructor();
  ObjectType implicitProto = subObject.getImplicitPrototype();
  ObjectType declaredSuper =
      implicitProto == null ? null : implicitProto.getImplicitPrototype();
  if (declaredSuper != null && declaredSuper.isTemplatizedType()) {
    declaredSuper =
        declaredSuper.toMaybeTemplatizedType().getReferencedType();
  }
  if (declaredSuper != null &&
      !(superObject instanceof UnknownType) &&
      !declaredSuper.isEquivalentTo(superObject)) {
    if (declaredSuper.isEquivalentTo(getNativeType(OBJECT_TYPE))) {
      registerMismatch(superObject, declaredSuper, report(
          t.makeError(n, MISSING_EXTENDS_TAG_WARNING, subObject.toString())));
    } else {
      mismatch(t.getSourceName(), n,
          "mismatch in declaration of superclass type",
          superObject, declaredSuper);
    }

    // Correct the super type.
    if (!subCtor.hasCachedValues()) {
      subCtor.setPrototypeBasedOn(superObject);
    }
  }
}