/** @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; }
/** * Determines if the specified type is exempt from standard invariant templatized typing rules. */ static boolean isIThenableSubtype(JSType type) { if (type.isTemplatizedType()) { TemplatizedType ttype = type.toMaybeTemplatizedType(); return ttype.getTemplateTypeMap().hasTemplateKey(ttype.registry.getThenableValueKey()); } return false; }
@Override final boolean hasAnyTemplateTypesInternal() { return getTemplateTypeMap().numUnfilledTemplateKeys() > 0 || typeOfThis.hasAnyTemplateTypes() || call.hasAnyTemplateTypes(); }
private boolean isStructuralInterfacePrototype(JSType type) { return type.isFunctionPrototypeType() && type.toObjectType().getOwnerFunction().isStructuralInterface(); } }
private JSType applyCommonRestriction(JSType type) { if (target.isUnknownType()) { return type; } FunctionType funcTarget = target.toMaybeFunctionType(); if (funcTarget.hasInstanceType()) { return type.getGreatestSubtype(funcTarget.getInstanceType()); } return null; } }
@Override public JSType caseUnionType(UnionType type) { if (target.isUnknownType()) { return type; } FunctionType funcTarget = target.toMaybeFunctionType(); if (funcTarget.hasInstanceType()) { return type.getRestrictedUnion(funcTarget.getInstanceType()); } return null; }
@Override public TernaryValue testForEquality(JSType that) { TernaryValue result = super.testForEquality(that); if (result != null) { return result; } if (that.isUnknownType() || that.isSubtype( getNativeType(JSTypeNative.OBJECT_NUMBER_STRING_BOOLEAN))) { return UNKNOWN; } return FALSE; }
@Override public TernaryValue testForEquality(JSType that) { if (UNKNOWN.equals(super.testForEquality(that))) { return UNKNOWN; } if (that.isSubtype(this) || that.isSubtype(getNativeType(JSTypeNative.NULL_TYPE))) { return TRUE; } return FALSE; }
@Override public TernaryValue testForEquality(JSType that) { TernaryValue result = super.testForEquality(that); if (result != null) { return result; } if (that.isUnknownType() || that.isSubtypeOf( getNativeType(JSTypeNative.OBJECT_NUMBER_STRING_BOOLEAN))) { return UNKNOWN; } return FALSE; }
@Override public TernaryValue testForEquality(JSType that) { TernaryValue result = super.testForEquality(that); if (result != null) { return result; } if (that.isUnknownType() || that.isSubtypeOf( getNativeType(JSTypeNative.OBJECT_NUMBER_STRING_BOOLEAN))) { return UNKNOWN; } return FALSE; }
@Override public TernaryValue testForEquality(JSType that) { if (UNKNOWN.equals(super.testForEquality(that))) { return UNKNOWN; } if (that.isSubtypeOf(this) || that.isSubtypeOf(getNativeType(JSTypeNative.NULL_TYPE))) { return TRUE; } return FALSE; }
@Override boolean defineProperty(String name, JSType type, boolean inferred, Node propertyNode) { if (hasOwnDeclaredProperty(name)) { return false; } Property newProp = new Property( name, type, inferred, propertyNode); properties.putProperty(name, newProp); return true; }
private void finishPropertyContinuations() { ObjectType referencedObjType = getReferencedObjTypeInternal(); if (referencedObjType != null && !referencedObjType.isUnknownType() && propertyContinuations != null) { for (PropertyContinuation c : propertyContinuations) { c.commit(this); } } propertyContinuations = null; }
@Override public NominalTypeBuilder superClass() { FunctionType ctor = instance.getSuperClassConstructor(); if (ctor == null) { return null; } return new NominalTypeBuilderOti(ctor, ctor.getInstanceType()); }
@Override int recursionUnsafeHashCode() { if (hasReferenceName()) { return NamedType.nominalHashCode(this); } else { return super.hashCode(); } }
@Override public TernaryValue testForEquality(JSType that) { TernaryValue result = super.testForEquality(that); if (result != null) { return result; } if (that.canCastTo(getNativeType(SYMBOL_VALUE_OR_OBJECT_TYPE))) { return UNKNOWN; } return FALSE; }
@Override public boolean isObject() { if (isEnumElementType()) { return toMaybeEnumElementType().isObject(); } return super.isObject(); }
private static boolean isStructuralInterfacePrototype(JSType type) { if (!type.isFunctionPrototypeType()) { return false; } FunctionType constructor = type.toObjectType().getOwnerFunction(); return constructor != null && constructor.isStructuralInterface(); }
@Override public boolean hasAnyTemplateTypesInternal() { return getTemplateTypeMap().numUnfilledTemplateKeys() > 0 || typeOfThis.hasAnyTemplateTypes() || call.hasAnyTemplateTypes(); }
@Override boolean defineProperty(String name, JSType type, boolean inferred, Node propertyNode) { if (hasOwnDeclaredProperty(name)) { return false; } Property newProp = new Property( name, type, inferred, propertyNode); properties.putProperty(name, newProp); return true; }