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.TypePair
templateTypeMap
Modifier and Type | Method and Description |
---|---|
FunctionType |
getConstructor()
Gets this object's constructor.
|
ObjectType |
getImplicitPrototype()
Gets the implicit prototype (a.k.a.
|
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,
com.google.javascript.rhino.jstype.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(String name)
Removes the declared or inferred property from this ObjectType.
|
void |
setPropertyJSDocInfo(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.
|
canBeCalled, checkExtendsLoop, checkExtendsLoop, clearCachedValues, convertMethodToFunction, explicitlyImplOrExtInterface, extendTemplateTypeMapBasedOn, forgetParameterAndReturnTypes, getAllImplementedInterfaces, getBindReturnType, getExtendedInterfaces, getExtendedInterfacesCount, getImplementedInterfaces, getInstanceType, 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, setPrototypeBasedOn, setSource, setStruct, toDebugHashCodeString, treatThisTypesAsCovariant
getCtorExtendedInterfaces, getCtorImplementedInterfaces, getOwnerFunction, isAnonymous, isNativeObjectType, matchConstraint, matchRecordTypeConstraint, setPropertyNode, unboxesTo
cast, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, findPropertyType, getDisplayName, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyJSDocInfo, getOwnSlot, getParentScope, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyNames, getPropertyNode, getRootNode, getTemplateTypes, hasOwnProperty, hasProperty, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isStructuralType, isUnknownType, setJSDocInfo, testForEquality
autobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, collapseUnion, dereference, differsFrom, equals, extendTemplateTypeMap, getGreatestSubtype, getLeastSupertype, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, hasAnyTemplateTypes, hasDisplayName, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBottom, isCheckedUnknownType, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isNamedType, isNominalConstructor, isNominalType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isRecordType, isRegexpType, isResolved, isString, isStringObjectType, isStringValueType, isStruct, isSubtypeOf, isSubtypeWithoutStructuralTyping, isTemplateType, isTemplatizedType, isUnionType, isVoidable, isVoidType, matchesInt32Context, matchesUint32Context, resolve, restrictByNotNullOrUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toNonNullAnnotationString, toObjectType, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isBottom, isEquivalentTo, isFunctionType, isSubtypeOf, isUnknownType, restrictByNotNullOrUndefined, toMaybeObjectType
public boolean isSubtype(JSType that)
FunctionType
this
is a subtype of that
with regard to
the prototype chain.isSubtype
in class FunctionType
this <: that
protected boolean isSubtype(JSType that, com.google.javascript.rhino.jstype.JSType.ImplCache implicitImplCache)
JSType
isSubtype
in class FunctionType
implicitImplCache
- 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()
JSType
toMaybeFunctionType
in interface TypeI
toMaybeFunctionType
in class FunctionType
public boolean isNoObjectType()
isNoObjectType
in class JSType
public ObjectType getImplicitPrototype()
ObjectType
[[Prototype]]
property).getImplicitPrototype
in class PrototypeObjectType
public String getReferenceName()
ObjectType
getReferenceName
in interface FunctionTypeI
getReferenceName
in class PrototypeObjectType
null
if this is an anonymous
objectpublic boolean hasReferenceName()
ObjectType
hasReferenceName
in class PrototypeObjectType
public boolean matchesNumberContext()
JSType
matchesNumberContext
in class PrototypeObjectType
public boolean matchesObjectContext()
JSType
Object
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 PrototypeObjectType
public boolean matchesStringContext()
JSType
String
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 PrototypeObjectType
public int hashCode()
hashCode
in class FunctionType
public boolean removeProperty(String name)
ObjectType
removeProperty
in class PrototypeObjectType
name
- the property's namepublic void setPropertyJSDocInfo(String propertyName, JSDocInfo info)
ObjectType
JSDocInfo
on its definition.setPropertyJSDocInfo
in class PrototypeObjectType
info
- JSDocInfo
for the property definition. May be
null
.public <T> T visit(Visitor<T> visitor)
JSType
visit
in class FunctionType
Visitor
public FunctionType getConstructor()
ObjectType
getConstructor
in interface ObjectTypeI
getConstructor
in class PrototypeObjectType
null
if it is a native
object (constructed natively v.s. by instantiation of a function)Copyright © 2009–2023 Google. All rights reserved.