EnumElementType(JSTypeRegistry registry, JSType elementType, String name, EnumType enumType) { super(registry); this.primitiveType = elementType; this.primitiveObjectType = elementType.toObjectType(); this.name = name; this.enumType = enumType; }
/** * A null-safe version of JSType#toObjectType. */ public static ObjectType cast(JSType type) { return type == null ? null : type.toObjectType(); }
@Override public ObjectType toMaybeObjectType() { return toObjectType(); }
/** * A null-safe version of JSType#toObjectType. */ public static ObjectType cast(JSType type) { return type == null ? null : type.toObjectType(); }
EnumElementType(JSTypeRegistry registry, JSType elementType, String name, EnumType enumType) { super(registry); this.primitiveType = elementType; this.primitiveObjectType = elementType.toObjectType(); this.name = name; this.enumType = enumType; }
/** * Dereferences a type for property access. * * Filters null/undefined, autoboxes the resulting type, and returns it * iff it's an object. If not an object, returns null. */ @Nullable public final ObjectType dereference() { return autobox().toObjectType(); }
/** * Determines if the supplied type should be checked as a bivariant * templatized type rather the standard invariant templatized type * rules. */ static boolean isBivariantType(JSType type) { ObjectType objType = type.toObjectType(); return objType != null // && objType.isNativeObjectType() && BIVARIANT_TYPES.contains(objType.getReferenceName()); }
/** * Gets the type of instance of this function. * * @throws IllegalStateException if this function is not a constructor (see {@link * #isConstructor()}). */ public final ObjectType getInstanceType() { Preconditions.checkState(hasInstanceType(), "Expected a constructor; got %s", this); return typeOfThis.toObjectType(); }
/** * Dereference a type for property access. * * Filters null/undefined, autoboxes the resulting type, and returns it * iff it's an object. */ public final ObjectType dereference() { return autobox().toObjectType(); }
/** * Gets the type of instance of this function. * @throws IllegalStateException if this function is not a constructor * (see {@link #isConstructor()}). */ @Override public ObjectType getInstanceType() { Preconditions.checkState(hasInstanceType()); return typeOfThis.toObjectType(); }
@Override public Iterable<ObjectType> getCtorImplementedInterfaces() { LinkedHashSet<ObjectType> resolvedImplementedInterfaces = new LinkedHashSet<>(); for (ObjectType obj : getReferencedObjTypeInternal().getCtorImplementedInterfaces()) { resolvedImplementedInterfaces.add(obj.visit(replacer).toObjectType()); } return resolvedImplementedInterfaces; }
private boolean isInterface(JSType type) { ObjectType objType = type.toObjectType(); if (objType != null) { JSType constructor = objType.getConstructor(); return constructor != null && constructor.isInterface(); } return false; }
@Override public Iterable<ObjectType> getCtorExtendedInterfaces() { LinkedHashSet<ObjectType> resolvedExtendedInterfaces = new LinkedHashSet<>(); for (ObjectType obj : getReferencedObjTypeInternal().getCtorExtendedInterfaces()) { resolvedExtendedInterfaces.add(obj.visit(replacer).toObjectType()); } return resolvedExtendedInterfaces; }
private boolean isInterface(JSType type) { ObjectType objType = type.toObjectType(); if (objType != null) { JSType constructor = objType.getConstructor(); return constructor != null && constructor.isInterface(); } return false; }
/** * Determines if the specified type is exempt from standard invariant * templatized typing rules. */ static boolean isExemptFromTemplateTypeInvariance(JSType type) { ObjectType objType = type.toObjectType(); return objType == null || COVARIANT_TYPES.contains(objType.getReferenceName()); }
private boolean isStructuralInterfacePrototype(JSType type) { return type.isFunctionPrototypeType() && type.toObjectType().getOwnerFunction().isStructuralInterface(); } }
private static boolean isStructuralInterfacePrototype(JSType type) { if (!type.isFunctionPrototypeType()) { return false; } FunctionType constructor = type.toObjectType().getOwnerFunction(); return constructor != null && constructor.isStructuralInterface(); }
/** @return return an immutable list of template types of the given builtin. */ public ImmutableList<TemplateType> maybeGetTemplateTypesOfBuiltin(String fnName) { JSType type = getType(null, fnName); ObjectType objType = type == null ? null : type.toObjectType(); if (objType != null && objType.isNativeObjectType()) { ImmutableList<TemplateType> templateKeys = objType.getTemplateTypeMap().getUnfilledTemplateKeys(); return templateKeys; } return null; }
private ObjectType getThisTypeForCollectingProperties() { Node rootNode = scope.getRootNode(); if (rootNode.isFromExterns()) return null; JSType type = rootNode.getJSType(); if (type == null || !type.isFunctionType()) return null; FunctionType fnType = type.toMaybeFunctionType(); JSType fnThisType = fnType.getTypeOfThis(); return fnThisType.isUnknownType() ? null : fnThisType.toObjectType(); }
private JSType evalPropType(Node ttlAst, NameResolver nameResolver) { JSType type = evalInternal(getCallArgument(ttlAst, 1), nameResolver); ObjectType objType = type.toObjectType(); if (objType == null) { reportWarning(ttlAst, PROPTYPE_INVALID, type.toString()); return getUnknownType(); } return objType.getPropertyType(getCallArgument(ttlAst, 0).getString()); }