public class RecordType extends PrototypeObjectType
JSType.EqCache, JSType.ImplCache, JSType.MatchStatus, JSType.TypePair
Modifier and Type | Field and Description |
---|---|
private boolean |
declared |
private boolean |
isFrozen |
private static long |
serialVersionUID |
ALPHA, registry, templateTypeMap
Constructor and Description |
---|
RecordType(JSTypeRegistry registry,
java.util.Map<java.lang.String,RecordTypeBuilder.RecordProperty> properties) |
RecordType(JSTypeRegistry registry,
java.util.Map<java.lang.String,RecordTypeBuilder.RecordProperty> properties,
boolean declared)
Creates a record type.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
defineProperty(java.lang.String propertyName,
JSType type,
boolean inferred,
Node propertyNode)
Defines a property.
|
(package private) JSType |
getGreatestSubtypeHelper(JSType that) |
ObjectType |
getImplicitPrototype()
Gets the implicit prototype (a.k.a.
|
boolean |
isStructuralType() |
boolean |
isSubtype(JSType that)
Checks whether
this is a subtype of that . |
protected boolean |
isSubtype(JSType that,
JSType.ImplCache implicitImplCache)
checking isSubtype with structural interface matching
|
(package private) boolean |
isSynthetic() |
RecordType |
toMaybeRecordType()
Downcasts this to a RecordType, or returns null if this is not
a RecordType.
|
canBeCalled, getConstructor, getCtorExtendedInterfaces, getCtorImplementedInterfaces, getOwnerFunction, getPropertyMap, getReferenceName, hasCachedValues, hasReferenceName, isAnonymous, isNativeObjectType, isPrettyPrint, isSubtype, matchConstraint, matchesNumberContext, matchesObjectContext, matchesStringContext, matchRecordTypeConstraint, removeProperty, resolveInternal, setImplicitPrototype, setOwnerFunction, setPrettyPrint, setPropertyJSDocInfo, setPropertyNode, toStringHelper, unboxesTo
cast, checkStructuralEquivalenceHelper, clearCachedValues, collectPropertyNames, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, detectImplicitPrototypeCycle, detectInheritanceCycle, findPropertyType, getDisplayName, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyJSDocInfo, getOwnPropertyNames, getOwnSlot, getParentScope, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyNames, getPropertyNode, getPropertyType, getPropertyTypeMap, getRootNode, getSlot, getTemplateTypes, getTypeOfThis, hasOwnDeclaredProperty, hasOwnProperty, hasProperty, isFunctionPrototypeType, isImplicitPrototype, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isStructuralSubtype, isUnknownType, setJSDocInfo, testForEquality, visit, visit
autobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, checkEquivalenceHelper, checkEquivalenceHelper, collapseUnion, dereference, differsFrom, equals, extendTemplateTypeMap, filterNoResolvedType, getGreatestSubtype, getGreatestSubtype, getLeastSupertype, getLeastSupertype, getNativeType, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, hasAnyTemplateTypes, hasAnyTemplateTypesInternal, hasDisplayName, hashCode, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBottom, isCheckedUnknownType, isConstructor, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExemptFromTemplateTypeInvariance, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isInstanceType, isInterface, isNamedType, isNominalConstructor, isNominalType, isNoObjectType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isOrdinaryFunction, isRecordType, isRegexpType, isResolved, isString, isStringObjectType, isStringValueType, isStruct, isStructuralInterface, isSubtypeHelper, isSubtypeOf, isSubtypeWithoutStructuralTyping, isTemplateType, isTemplatizedType, isTheObjectType, isUnionType, isVoidable, isVoidType, matchesInt32Context, matchesUint32Context, resolve, restrictByNotNullOrUndefined, safeResolve, setResolvedTypeInternal, setValidator, testForEqualityHelper, toAnnotationString, toDebugHashCodeString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toNonNullAnnotationString, toObjectType, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isBottom, isConstructor, isEquivalentTo, isFunctionType, isInterface, isSubtypeOf, restrictByNotNullOrUndefined, toMaybeFunctionType, toMaybeObjectType
private static final long serialVersionUID
private final boolean declared
private boolean isFrozen
RecordType(JSTypeRegistry registry, java.util.Map<java.lang.String,RecordTypeBuilder.RecordProperty> properties)
RecordType(JSTypeRegistry registry, java.util.Map<java.lang.String,RecordTypeBuilder.RecordProperty> properties, boolean declared)
registry
- The type registry under which this type lives.properties
- A map of all the properties of this record type.declared
- Whether this is a declared or synthesized type.
A synthesized record type is just used for bookkeeping
in the type system. A declared record type was actually used in the
user's program.java.lang.IllegalStateException
- if the RecordProperty
associated
with a property is null.boolean isSynthetic()
public ObjectType getImplicitPrototype()
ObjectType
[[Prototype]]
property).getImplicitPrototype
in class PrototypeObjectType
boolean 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 PrototypeObjectType
propertyName
- 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 RecordType toMaybeRecordType()
JSType
toMaybeRecordType
in class JSType
public boolean isStructuralType()
isStructuralType
in class ObjectType
public boolean isSubtype(JSType that)
JSType
this
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.isSubtype
in class PrototypeObjectType
this <: that
protected boolean isSubtype(JSType that, JSType.ImplCache implicitImplCache)
JSType
isSubtype
in class PrototypeObjectType
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.