public class NoType extends NoObjectType
var x = null;
if (x) {
f(x);
}
We need to be able to assign x
a type within the f(x)
call. Since it has no possible type, we assign x
the NoType,
so that f(x)
is legal no matter what the type of f
's
first argument is.JSType.TypePair
EMPTY_TYPE_COMPONENT, ENUMDECL, NOT_A_CLASS, NOT_A_TYPE, NOT_ENUMDECL, templateTypeMap, UNKNOWN_NAME
Modifier and Type | Method and Description |
---|---|
Iterable<ObjectType> |
getCtorExtendedInterfaces()
Gets the interfaces extended by the interface associated with this type.
|
Iterable<ObjectType> |
getCtorImplementedInterfaces()
Gets the interfaces implemented by the ctor associated with this type.
|
FunctionType |
getOwnerFunction()
Gets the owner of this if it's a function prototype.
|
BooleanLiteralSet |
getPossibleToBooleanOutcomes()
Computes the set of possible outcomes of the
ToBoolean predicate
for this type. |
boolean |
hasReferenceName()
Returns true if the object is named.
|
boolean |
isNativeObjectType()
Whether this is a built-in object.
|
boolean |
isNoObjectType() |
boolean |
isNoType() |
boolean |
isNullable()
Tests whether this type is nullable.
|
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. |
void |
matchConstraint(JSType constraint)
Modify this type so that it matches the specified type.
|
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. |
void |
matchRecordTypeConstraint(ObjectType constraintObj) |
JSType |
unboxesTo()
Turn an object type to its corresponding scalar type.
|
<T> T |
visit(Visitor<T> visitor)
Visit this type with the given visitor.
|
getConstructor, getImplicitPrototype, getReferenceName, hashCode, removeProperty, setPropertyJSDocInfo, toMaybeFunctionType
canBeCalled, clearCachedValues, cloneWithoutArrowType, extendTemplateTypeMapBasedOn, getAllExtendedInterfaces, getAllImplementedInterfaces, getBindReturnType, getExtendedInterfaces, getExtendedInterfacesCount, getImplementedInterfaces, getInstanceType, getMaxArguments, getMinArguments, getOwnImplementedInterfaces, getOwnPropertyNames, getParameters, getParametersNode, getPropertyType, getPrototype, getReturnType, getSlot, getSource, getSubTypes, getSuperClassConstructor, getTopDefiningInterface, getTopMostDefiningType, getTypeOfThis, hasAnyTemplateTypesInternal, hasCachedValues, hasEqualCallType, hasImplementedInterfaces, hasInstanceType, isConstructor, isInstanceType, isInterface, isOrdinaryFunction, isReturnTypeInferred, makesDicts, makesStructs, setDict, setExtendedInterfaces, setImplementedInterfaces, setPrototypeBasedOn, setSource, setStruct, toDebugHashCodeString
cast, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, findPropertyType, getDisplayName, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyJSDocInfo, getOwnSlot, getParentScope, getPropertiesCount, getPropertyNames, getPropertyNode, getRootNode, getTemplateTypes, hasOwnProperty, hasProperty, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isUnknownType, setJSDocInfo, testForEquality
autobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, clearResolved, collapseUnion, dereference, differsFrom, equals, extendTemplateTypeMap, getGreatestSubtype, getLeastSupertype, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, hasAnyTemplateTypes, hasDisplayName, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isCheckedUnknownType, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isFunctionType, isGlobalThisType, isInvariant, isNominalConstructor, isNominalType, isNoResolvedType, isNullType, isNumber, isNumberObjectType, isNumberValueType, isRecordType, isRegexpType, isResolved, isString, isStringObjectType, isStringValueType, isStruct, isTemplateType, isTemplatizedType, isUnionType, isVoidType, matchesInt32Context, matchesUint32Context, resolve, restrictByNotNullOrUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeTemplateType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeTemplatizedType, toMaybeUnionType, toObjectType, toString
public boolean isNoObjectType()
isNoObjectType
in class NoObjectType
public boolean isNullable()
JSType
isNullable
in class JSType
public boolean isSubtype(JSType that)
FunctionType
this
is a subtype of that
with regard to
the prototype chain.isSubtype
in class NoObjectType
this <: that
public BooleanLiteralSet getPossibleToBooleanOutcomes()
JSType
ToBoolean
predicate
for this type. The ToBoolean
predicate is defined by the ECMA-262
standard, 3rd edition. Its behavior for simple types can be
summarized by the following table:
type | result |
---|---|
undefined | {false} |
null | {false} |
boolean | {true, false} |
number | {true, false} |
string | {true, false} |
Object | {true} |
getPossibleToBooleanOutcomes
in class ObjectType
public boolean matchesNumberContext()
JSType
matchesNumberContext
in class NoObjectType
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 NoObjectType
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 NoObjectType
public <T> T visit(Visitor<T> visitor)
JSType
visit
in class NoObjectType
Visitor
public JSType unboxesTo()
JSType
public boolean hasReferenceName()
ObjectType
hasReferenceName
in class ObjectType
public boolean isNativeObjectType()
isNativeObjectType
in class ObjectType
public FunctionType getOwnerFunction()
ObjectType
getOwnerFunction
in class ObjectType
public Iterable<ObjectType> getCtorImplementedInterfaces()
ObjectType
getCtorImplementedInterfaces
in class ObjectType
public Iterable<ObjectType> getCtorExtendedInterfaces()
ObjectType
getCtorExtendedInterfaces
in class ObjectType
public void matchConstraint(JSType constraint)
JSType
matchConstraint
in class JSType
public void matchRecordTypeConstraint(ObjectType constraintObj)
Copyright © 2009–2016 Google. All rights reserved.