com.google.javascript.rhino.jstype.EnumType

Here are the examples of the java api class com.google.javascript.rhino.jstype.EnumType taken from open source projects.

1. TypeCheck#checkEnumAlias()

Project: closure-compiler
File: TypeCheck.java
/**
   * <p>Checks enum aliases.
   *
   * <p>We verify that the enum element type of the enum used
   * for initialization is a subtype of the enum element type of
   * the enum the value is being copied in.</p>
   *
   * <p>Example:</p>
   * <pre>var myEnum = myOtherEnum;</pre>
   *
   * <p>Enum aliases are irregular, so we need special code for this :(</p>
   *
   * @param value the value used for initialization of the enum
   */
private void checkEnumAlias(NodeTraversal t, JSDocInfo declInfo, Node value) {
    if (declInfo == null || !declInfo.hasEnumParameterType()) {
        return;
    }
    JSType valueType = getJSType(value);
    if (!valueType.isEnumType()) {
        return;
    }
    EnumType valueEnumType = valueType.toMaybeEnumType();
    JSType valueEnumPrimitiveType = valueEnumType.getElementsType().getPrimitiveType();
    validator.expectCanAssignTo(t, value, valueEnumPrimitiveType, declInfo.getEnumParameterType().evaluate(t.getTypedScope(), typeRegistry), "incompatible enum element types");
}