public class NoObjectType extends FunctionType
Although JavaScript programmers can't explicitly denote the bottom Object type, it comes up in
static analysis. For example, if we have:
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.
FunctionType.BuilderJSType.HasPropertyKind, JSType.Nullability, JSType.SubtypingMode, JSType.TypePairtemplateTypeMap| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
isNoObjectType() |
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 |
matchesSymbolContext()
This predicate is used to test whether a given type can appear in a
symbol context such as property access. |
boolean |
removeProperty(java.lang.String name)
Removes the declared or inferred property from this ObjectType.
|
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.
|
<T> T |
visit(Visitor<T> visitor)
Visit this type with the given visitor.
|
acceptsArguments, builder, canBeCalled, checkExtendsLoop, clearCachedValues, forgetParameterAndReturnTypes, getAllImplementedInterfaces, getAncestorInterfaces, getBindReturnType, getClosurePrimitive, getConstructorOnlyTemplateParameters, getDirectSubTypes, getExtendedInterfaces, getExtendedInterfacesCount, getImplementedInterfaces, getInstanceType, getMaxArity, getMinArity, getOwnImplementedInterfaces, getOwnPropertyNames, getParameters, getParametersNode, getParameterTypes, getPropertyType, getPropertyTypeMap, getPrototype, getPrototypeProperty, getReturnType, getSlot, getSource, getSuperClassConstructor, getTypeOfThis, hasCachedValues, hasEqualCallType, hasImplementedInterfaces, hasInstanceType, hasProperties, isAbstract, isConstructor, isInstanceType, isInterface, isOrdinaryFunction, isReturnTypeInferred, isStructuralInterface, makesDicts, makesStructs, setDict, setExplicitUnrestricted, setExtendedInterfaces, setImplementedInterfaces, setImplicitMatch, setPrototypeBasedOn, setSource, setStructgetCtorExtendedInterfaces, getCtorImplementedInterfaces, getOwnerFunction, getTemplateParamCount, isAnonymous, isNativeObjectType, matchConstraint, matchRecordTypeConstraint, setPropertyNode, unboxesTocast, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, findClosestDefinition, findPropertyTypeWithoutConsideringTemplateTypes, getClosestDefiningType, getDisplayName, getEnumeratedTypeOfEnumObject, getImplicitPrototypeChain, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getOwnPropertyKind, getOwnSlot, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyDefSite, getPropertyJSDocInfo, getPropertyKind, getPropertyNames, getPropertyNode, getRawType, getTemplateTypes, getTopMostDefiningType, hasOwnProperty, hasReferenceName, isAmbiguousObject, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isStructuralType, isUnknownType, setJSDocInfo, testForEqualityareIdentical, assertFunctionType, assertObjectType, autobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, collapseUnion, containsReferenceAncestor, dereference, differsFrom, equals, findPropertyType, getEnumeratedTypeOfEnumElement, getGreatestSubtype, getGreatestSubtypeWithProperty, getLeastSupertype, getPropertyKind, getRestrictedTypeGivenOutcome, getTemplateTypeMap, getTypeParameters, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, getUnionMembers, hasAnyTemplateTypes, hasDisplayName, hashCode, hasProperty, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBoxableScalar, isCheckedUnknownType, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isLiteralObject, isNamedType, isNominalConstructor, isNominalType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObjectType, isRawTypeOfTemplatizedType, isRecordType, isRegexpType, isResolved, isSomeUnknownType, isString, isStringObjectType, isStringValueType, isStruct, isSubtype, isSubtype, isSubtypeOf, isSubtypeOf, isSubtypeWithoutStructuralTyping, isSuccessfullyResolved, isSymbol, isSymbolObjectType, isSymbolValueType, isTemplateType, isTemplatizedType, isUnionType, isUnresolved, isUnresolvedOrResolvedUnknown, isUnsuccessfullyResolved, isVoidable, isVoidType, loosenTypecheckingDueToForwardReferencedSupertype, mergeSupertypeTemplateTypes, resolve, restrictByNotNull, restrictByNotNullOrUndefined, restrictByNotUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toObjectType, toStringpublic final FunctionType toMaybeFunctionType()
JSTypeFor the purposes of this function, we define a MaybeFunctionType as any type in the sub-lattice { x | LEAST_FUNCTION_TYPE <= x <= GREATEST_FUNCTION_TYPE } This definition excludes bottom types like NoType and NoObjectType.
This definition is somewhat arbitrary and axiomatic, but this is the definition that makes the most sense for the most callers.
toMaybeFunctionType in class FunctionTypepublic boolean isNoObjectType()
isNoObjectType in class JSTypepublic final ObjectType getImplicitPrototype()
ObjectType[[Prototype]] property).getImplicitPrototype in class PrototypeObjectTypepublic java.lang.String getReferenceName()
ObjectTypeReturning an empty string means something different than returning null. An empty string may
indicate an anonymous constructor, which we treat differently than a literal type without a
reference name. e.g. in InstanceObjectType.appendTo(TypeStringBuilder)
getReferenceName in class PrototypeObjectTypenull if this is an anonymous objectpublic final boolean matchesNumberContext()
JSTypematchesNumberContext in class PrototypeObjectTypepublic final 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 final 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 final boolean matchesSymbolContext()
JSTypesymbol context such as property access.matchesSymbolContext in class PrototypeObjectTypepublic final boolean removeProperty(java.lang.String name)
ObjectTyperemoveProperty in class PrototypeObjectTypename - the property's namepublic final 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 FunctionTypeVisitorpublic final FunctionType getConstructor()
ObjectTypegetConstructor in class FunctionTypenull if it is a native
object (constructed natively v.s. by instantiation of a function)Copyright © 2009-2020 Google. All Rights Reserved.