public class NoObjectType extends FunctionType
var x = function() {};
if (x instanceof Array) {
f(x);
}
We need to be able to assign x a type within the f(x)
call. It has no possible type, but x would not be legal if f
expected a string. So we assign it the NoObjectType.JSType.EqCache, JSType.ImplCache, JSType.MatchStatus, JSType.TypePair| Modifier and Type | Field and Description |
|---|---|
private static long |
serialVersionUID |
ALPHA, registry, templateTypeMap| Constructor and Description |
|---|
NoObjectType(JSTypeRegistry registry) |
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
defineProperty(java.lang.String propertyName,
JSType type,
boolean inferred,
Node propertyNode)
Defines a property.
|
FunctionType |
getConstructor()
Gets this object's constructor.
|
ObjectType |
getImplicitPrototype()
Gets the implicit prototype (a.k.a.
|
java.lang.String |
getReferenceName()
Gets the reference name for this object.
|
int |
hashCode() |
boolean |
hasReferenceName()
Returns true if the object is named.
|
boolean |
isNoObjectType() |
boolean |
isSubtype(JSType that)
A function is a subtype of another if their call methods are related via
subtyping and
this is a subtype of that with regard to
the prototype chain. |
protected boolean |
isSubtype(JSType that,
JSType.ImplCache implicitImplCache)
checking isSubtype with structural interface matching
|
boolean |
matchesNumberContext()
This predicate is used to test whether a given type can appear in a
numeric context, such as an operand of a multiply operator.
|
boolean |
matchesObjectContext()
This predicate is used to test whether a given type can appear in an
Object context, such as the expression in a with statement. |
boolean |
matchesStringContext()
This predicate is used to test whether a given type can appear in a
String context, such as an operand of a string concat (+) operator. |
boolean |
removeProperty(java.lang.String name)
Removes the declared or inferred property from this ObjectType.
|
(package private) JSType |
resolveInternal(ErrorReporter t,
StaticTypedScope<JSType> scope) |
void |
setPropertyJSDocInfo(java.lang.String propertyName,
JSDocInfo info)
Sets the docInfo for the specified property from the
JSDocInfo on its definition. |
FunctionType |
toMaybeFunctionType()
Downcasts this to a FunctionType, or returns null if this is not
a function.
|
(package private) java.lang.String |
toStringHelper(boolean forAnnotations)
Informally, a function is represented by
function (params): returnType where the params is a comma
separated list of types, the first one being a special
this:T if the function expects a known type for this. |
(package private) <T> T |
visit(RelationshipVisitor<T> visitor,
JSType that)
Visit the types with the given visitor.
|
<T> T |
visit(Visitor<T> visitor)
Visit this type with the given visitor.
|
addSubTypeIfNotPresent, canBeCalled, checkExtendsLoop, checkExtendsLoop, checkFunctionEquivalenceHelper, clearCachedValues, convertMethodToFunction, explicitlyImplOrExtInterface, extendTemplateTypeMapBasedOn, forgetParameterAndReturnTypes, forInterface, getAllImplementedInterfaces, getBindReturnType, getExtendedInterfaces, getExtendedInterfacesCount, getImplementedInterfaces, getInstanceType, getInternalArrowType, getMaxArguments, getMinArguments, getOwnImplementedInterfaces, getOwnPropertyNames, getParameters, getParametersNode, getPropertyType, getPropertyTypeMap, getPrototype, getReturnType, getSlot, getSource, getSubTypes, getSuperClassConstructor, getTopDefiningInterface, getTopMostDefiningType, getTypeOfThis, hasAnyTemplateTypesInternal, hasCachedValues, hasEqualCallType, hasImplementedInterfaces, hasInstanceType, hasProperties, isConstructor, isInstanceType, isInterface, isOrdinaryFunction, isReturnTypeInferred, isStructuralInterface, makesDicts, makesStructs, setDict, setExtendedInterfaces, setImplementedInterfaces, setImplicitMatch, setInstanceType, setPrototype, setPrototypeBasedOn, setPrototypeBasedOn, setSource, setStruct, supAndInfHelper, toDebugHashCodeString, treatThisTypesAsCovariantgetCtorExtendedInterfaces, getCtorImplementedInterfaces, getOwnerFunction, getPropertyMap, isAnonymous, isNativeObjectType, isPrettyPrint, isSubtype, matchConstraint, matchRecordTypeConstraint, setImplicitPrototype, setOwnerFunction, setPrettyPrint, setPropertyNode, unboxesTocast, checkStructuralEquivalenceHelper, collectPropertyNames, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, detectImplicitPrototypeCycle, detectInheritanceCycle, findPropertyType, getDisplayName, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyJSDocInfo, getOwnSlot, getParentScope, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyNames, getPropertyNode, getRootNode, getTemplateTypes, hasOwnDeclaredProperty, hasOwnProperty, hasProperty, isFunctionPrototypeType, isImplicitPrototype, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isStructuralSubtype, isStructuralType, isUnknownType, setJSDocInfo, testForEqualityautobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, checkEquivalenceHelper, checkEquivalenceHelper, collapseUnion, dereference, differsFrom, equals, extendTemplateTypeMap, filterNoResolvedType, getGreatestSubtype, getGreatestSubtype, getLeastSupertype, getLeastSupertype, getNativeType, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, hasAnyTemplateTypes, hasDisplayName, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBottom, isCheckedUnknownType, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExemptFromTemplateTypeInvariance, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isNamedType, isNominalConstructor, isNominalType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isRecordType, isRegexpType, isResolved, isString, isStringObjectType, isStringValueType, isStruct, isSubtypeHelper, isSubtypeOf, isSubtypeWithoutStructuralTyping, isTemplateType, isTemplatizedType, isTheObjectType, isUnionType, isVoidable, isVoidType, matchesInt32Context, matchesUint32Context, resolve, restrictByNotNullOrUndefined, safeResolve, setResolvedTypeInternal, setValidator, testForEqualityHelper, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toNonNullAnnotationString, toObjectType, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitisBottom, isEquivalentTo, isFunctionType, isSubtypeOf, isUnknownType, restrictByNotNullOrUndefined, toMaybeObjectTypeprivate static final long serialVersionUID
NoObjectType(JSTypeRegistry registry)
public boolean isSubtype(JSType that)
FunctionTypethis is a subtype of that with regard to
the prototype chain.isSubtype in class FunctionTypethis <: thatprotected boolean isSubtype(JSType that, JSType.ImplCache implicitImplCache)
JSTypeisSubtype in class FunctionTypeimplicitImplCache - a cache that records the checked
or currently checking type pairs, for example, if previous
checking found that constructor C is a subtype of interface I,
then in the cache, table key <I,C> maps to IMPLEMENT status.public FunctionType toMaybeFunctionType()
JSTypetoMaybeFunctionType in interface TypeItoMaybeFunctionType in class FunctionTypepublic boolean isNoObjectType()
isNoObjectType in class JSTypepublic ObjectType getImplicitPrototype()
ObjectType[[Prototype]] property).getImplicitPrototype in class PrototypeObjectTypepublic java.lang.String getReferenceName()
ObjectTypegetReferenceName in interface FunctionTypeIgetReferenceName in class PrototypeObjectTypenull if this is an anonymous
objectpublic boolean hasReferenceName()
ObjectTypehasReferenceName in class PrototypeObjectTypepublic boolean matchesNumberContext()
JSTypematchesNumberContext in class PrototypeObjectTypepublic boolean matchesObjectContext()
JSTypeObject context, such as the expression in a with statement.
Most types we will encounter, except notably null, have at least
the potential for converting to Object. Host defined objects can
get peculiar.matchesObjectContext in class PrototypeObjectTypepublic boolean matchesStringContext()
JSTypeString context, such as an operand of a string concat (+) operator.
All types have at least the potential for converting to String.
When we add externally defined types, such as a browser OM, we may choose
to add types that do not automatically convert to String.matchesStringContext in class PrototypeObjectTypepublic int hashCode()
hashCode in class FunctionTypeboolean defineProperty(java.lang.String propertyName,
JSType type,
boolean inferred,
Node propertyNode)
ObjectType
For clarity, callers should prefer ObjectType.defineDeclaredProperty(java.lang.String, com.google.javascript.rhino.jstype.JSType, com.google.javascript.rhino.Node) and
ObjectType.defineInferredProperty(java.lang.String, com.google.javascript.rhino.jstype.JSType, com.google.javascript.rhino.Node).
defineProperty in class FunctionTypepropertyName - the property's nametype - the typeinferred - true if this property's type is inferredpropertyNode - the node that represents the definition of property.
Depending on the actual sub-type the node type might be different.
The general idea is to have an estimate of where in the source code
this property is defined.public boolean removeProperty(java.lang.String name)
ObjectTyperemoveProperty in class PrototypeObjectTypename - the property's namepublic void setPropertyJSDocInfo(java.lang.String propertyName,
JSDocInfo info)
ObjectTypeJSDocInfo on its definition.setPropertyJSDocInfo in class PrototypeObjectTypeinfo - JSDocInfo for the property definition. May be
null.public <T> T visit(Visitor<T> visitor)
JSTypevisit in class FunctionTypeVisitor<T> T visit(RelationshipVisitor<T> visitor, JSType that)
JSTypevisit in class FunctionTypeRelationshipVisitorjava.lang.String toStringHelper(boolean forAnnotations)
FunctionTypefunction (params): returnType where the params is a comma
separated list of types, the first one being a special
this:T if the function expects a known type for this.toStringHelper in class FunctionTypeforAnnotations - Whether this is for use in code generator
annotations. Otherwise, it's for warnings.public FunctionType getConstructor()
ObjectTypegetConstructor in interface ObjectTypeIgetConstructor in class PrototypeObjectTypenull if it is a native
object (constructed natively v.s. by instantiation of a function)JSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> scope)