final class ArrowType extends JSType
FunctionType that models JavaScript's notion of functions.JSType.EqCache, JSType.ImplCache, JSType.MatchStatus, JSType.TypePair| Modifier and Type | Field and Description |
|---|---|
(package private) Node |
parameters |
(package private) JSType |
returnType |
(package private) boolean |
returnTypeInferred |
private static long |
serialVersionUID |
ALPHA, registry, templateTypeMap| Constructor and Description |
|---|
ArrowType(JSTypeRegistry registry,
Node parameters,
JSType returnType) |
ArrowType(JSTypeRegistry registry,
Node parameters,
JSType returnType,
boolean returnTypeInferred) |
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
checkArrowEquivalenceHelper(ArrowType that,
EquivalenceMethod eqMethod,
JSType.EqCache eqCache) |
JSType |
getGreatestSubtype(JSType that)
Gets the greatest subtype of
this and that. |
JSType |
getLeastSupertype(JSType that)
Gets the least supertype of
this and that. |
BooleanLiteralSet |
getPossibleToBooleanOutcomes()
Computes the set of possible outcomes of the
ToBoolean predicate
for this type. |
boolean |
hasAnyTemplateTypesInternal() |
(package private) boolean |
hasEqualParameters(ArrowType that,
EquivalenceMethod eqMethod,
JSType.EqCache eqCache) |
int |
hashCode() |
private boolean |
hasTemplatedParameterType() |
(package private) boolean |
hasUnknownParamsOrReturn() |
boolean |
isSubtype(JSType that)
Checks whether
this is a subtype of that. |
protected boolean |
isSubtype(JSType other,
JSType.ImplCache implicitImplCache)
checking isSubtype with structural interface matching
|
(package private) JSType |
resolveInternal(ErrorReporter t,
StaticTypedScope<JSType> scope) |
TernaryValue |
testForEquality(JSType that)
Compares
this and that. |
(package private) java.lang.String |
toStringHelper(boolean forAnnotations) |
(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.
|
autobox, autoboxesTo, canBeCalled, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, checkEquivalenceHelper, checkEquivalenceHelper, collapseUnion, dereference, differsFrom, equals, extendTemplateTypeMap, filterNoResolvedType, findPropertyType, getDisplayName, getGreatestSubtype, getJSDocInfo, getLeastSupertype, getNativeType, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, hasAnyTemplateTypes, hasDisplayName, hasProperty, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBottom, isCheckedUnknownType, isConstructor, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExemptFromTemplateTypeInvariance, isExplicitlyVoidable, isFunctionPrototypeType, isFunctionType, isGlobalThisType, isInstanceType, isInterface, isNamedType, isNominalConstructor, isNominalType, isNoObjectType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObject, isOrdinaryFunction, isRecordType, isRegexpType, isResolved, isString, isStringObjectType, isStringValueType, isStruct, isStructuralInterface, isStructuralType, isSubtypeHelper, isSubtypeOf, isSubtypeWithoutStructuralTyping, isTemplateType, isTemplatizedType, isTheObjectType, isUnionType, isUnknownType, isVoidable, isVoidType, matchConstraint, matchesInt32Context, matchesNumberContext, matchesObjectContext, matchesStringContext, matchesUint32Context, resolve, restrictByNotNullOrUndefined, safeResolve, setResolvedTypeInternal, setValidator, testForEqualityHelper, toAnnotationString, toDebugHashCodeString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toNonNullAnnotationString, toObjectType, toString, unboxesToprivate static final long serialVersionUID
final Node parameters
JSType returnType
final boolean returnTypeInferred
ArrowType(JSTypeRegistry registry, Node parameters, JSType returnType)
ArrowType(JSTypeRegistry registry, Node parameters, JSType returnType, boolean returnTypeInferred)
public boolean isSubtype(JSType that)
JSTypethis is a subtype of that.Note this function also returns true if this type structurally matches the protocol define by that type (if that type is an interface function type) Subtyping rules:
(T1, …, Tn) <: U if and only
Tk <: U for all k ∈ 1..n.U <: (T1, …, Tn) if and only
if U <: Tk for some index k.O1 is a subtype
of an object O2 if it has more properties
than O2 and all common properties are
pairwise subtypes.protected boolean isSubtype(JSType other, JSType.ImplCache implicitImplCache)
JSTypeboolean hasEqualParameters(ArrowType that, EquivalenceMethod eqMethod, JSType.EqCache eqCache)
that's parameter
spec.boolean checkArrowEquivalenceHelper(ArrowType that, EquivalenceMethod eqMethod, JSType.EqCache eqCache)
public JSType getLeastSupertype(JSType that)
JSTypethis and that.
The least supertype is the join (∨) or supremum of both types in the
type lattice.Examples:
number ∨ * = *number ∨ Object = (number, Object)Number ∨ Object = ObjectgetLeastSupertype in class JSTypethis ∨ thatpublic JSType getGreatestSubtype(JSType that)
JSTypethis and that.
The greatest subtype is the meet (∧) or infimum of both types in the
type lattice.Examples
Number ∧ Any = Anynumber ∧ Object = AnyNumber ∧ Object = NumbergetGreatestSubtype in class JSTypethis ∨ thatpublic TernaryValue testForEquality(JSType that)
JSTypethis and that.testForEquality in class JSTypeTernaryValue.TRUE if the comparison of values of
this type and that always succeed (such as
undefined compared to null)TernaryValue.FALSE if the comparison of values of
this type and that always fails (such as
undefined compared to number)TernaryValue.UNKNOWN if the comparison can succeed or
fail depending on the concrete valuespublic <T> T visit(Visitor<T> visitor)
JSType<T> T visit(RelationshipVisitor<T> visitor, JSType that)
JSTypevisit in class JSTypeRelationshipVisitorpublic BooleanLiteralSet getPossibleToBooleanOutcomes()
JSTypeToBoolean 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 JSTypeJSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> scope)
boolean hasUnknownParamsOrReturn()
java.lang.String toStringHelper(boolean forAnnotations)
toStringHelper in class JSTypeforAnnotations - Whether this is for use in code generator
annotations. Otherwise, it's for warnings.public boolean hasAnyTemplateTypesInternal()
hasAnyTemplateTypesInternal in class JSTypeprivate boolean hasTemplatedParameterType()