private FlowScope traverseGetElem(Node n, FlowScope scope) { scope = traverseChildren(n, scope); JSType type = getJSType(n.getFirstChild()).restrictByNotNullOrUndefined(); TemplateTypeMap typeMap = type.getTemplateTypeMap(); if (typeMap.hasTemplateType(registry.getObjectElementKey())) { n.setJSType(typeMap.getResolvedTemplateType(registry.getObjectElementKey())); } return dereferencePointer(n.getFirstChild(), scope); }
private JSType inferObjectPatternKeyType() { JSType patternType = patternTypeSupplier.get(); if (isRest) { return inferObjectRestType(patternType); } if (patternType == null || patternType.isUnknownType()) { return registry.getNativeType(JSTypeNative.UNKNOWN_TYPE); } switch (objectPatternKey.getToken()) { case STRING_KEY: JSType propertyType = patternType.findPropertyType(objectPatternKey.getString()); return propertyType != null ? propertyType : registry.getNativeType(JSTypeNative.UNKNOWN_TYPE); case COMPUTED_PROP: return patternType != null ? patternType .getTemplateTypeMap() .getResolvedTemplateType(registry.getObjectElementKey()) : registry.getNativeType(JSTypeNative.UNKNOWN_TYPE); default: throw new IllegalStateException("Unexpected key " + objectPatternKey); } }
private FlowScope traverseGetElem(Node n, FlowScope scope) { scope = traverseChildren(n, scope); Node indexKey = n.getLastChild(); JSType indexType = getJSType(indexKey); if (indexType.isSymbolValueType()) { // For now, allow symbols definitions/access on any type. In the future only allow them // on the subtypes for which they are defined. // TODO(b/77474174): Type well known symbol accesses. n.setJSType(unknownType); } else { JSType type = getJSType(n.getFirstChild()).restrictByNotNullOrUndefined(); TemplateTypeMap typeMap = type.getTemplateTypeMap(); if (typeMap.hasTemplateType(registry.getObjectElementKey())) { n.setJSType(typeMap.getResolvedTemplateType(registry.getObjectElementKey())); } } return tightenTypeAfterDereference(n.getFirstChild(), scope); }
objectType, templates.getResolvedTemplateType(registry.getObjectIndexKey()), templates.getResolvedTemplateType(registry.getObjectElementKey()));
TemplateType key = thisType.registry.getObjectElementKey(); JSType thisElement = thisTypeParams.getResolvedTemplateType(key); JSType thatElement = thatTypeParams.getResolvedTemplateType(key);
TemplateType key = thisType.registry.getObjectElementKey(); JSType thisElement = thisTypeParams.getResolvedTemplateType(key); JSType thatElement = thatTypeParams.getResolvedTemplateType(key);