if (type.hasAnyTemplateTypes() && !type.getTemplateTypeMap().isEmpty()) { List<String> realTemplateType = new ArrayList<>();
/** * Coerces this type to an Object type, then gets the type of the property whose name is given. * * <p>Unlike {@link ObjectType#getPropertyType}, returns null if the property is not found. * * @return The property's type. {@code null} if the current type cannot have properties, or if the * type is not found. */ @Nullable public final JSType findPropertyType(String propertyName) { @Nullable JSType propertyType = findPropertyTypeWithoutConsideringTemplateTypes(propertyName); if (propertyType == null) { return null; } // Do templatized type replacing logic here, and make this method final, to prevent a subclass // from forgetting to replace template types if (getTemplateTypeMap().isEmpty() || !propertyType.hasAnyTemplateTypes()) { return propertyType; } TemplateTypeMap typeMap = getTemplateTypeMap(); TemplateTypeMapReplacer replacer = new TemplateTypeMapReplacer(registry, typeMap); return propertyType.visit(replacer); }
public Void emitObjectType( ObjectType type, boolean extendingInstanceClass, boolean inExtendsImplementsPosition) { if (!type.getTemplateTypeMap().isEmpty() && !typeRegistry.getNativeType(OBJECT_TYPE).equals(type)) { return emitTemplatizedType(
/** * Find the property that's being overridden on this type, if any. * * <p>Said property could be a method, field, getter, or setter. We don't distinguish between * these when looking up a property type. */ private JSType findOverriddenProperty( ObjectType ownerType, String propName, TemplateTypeMap typeMap) { JSType result = null; // First, check to see if the property is implemented // on a superclass. JSType propType = ownerType.getPropertyType(propName); if (propType != null && !propType.isUnknownType()) { result = propType; } else { // If it's not, then check to see if it's implemented // on an implemented interface. for (ObjectType iface : ownerType.getCtorImplementedInterfaces()) { propType = iface.getPropertyType(propName); if (propType != null && !propType.isUnknownType()) { result = propType; break; } } } if (result != null && typeMap != null && !typeMap.isEmpty()) { result = result.visit(new TemplateTypeMapReplacer(typeRegistry, typeMap)); } return result; }
/** * Find the function that's being overridden on this type, if any. */ private FunctionType findOverriddenFunction( ObjectType ownerType, String propName, TemplateTypeMap typeMap) { FunctionType result = null; // First, check to see if the property is implemented // on a superclass. JSType propType = ownerType.getPropertyType(propName); if (propType != null && propType.isFunctionType()) { result = propType.toMaybeFunctionType(); } else { // If it's not, then check to see if it's implemented // on an implemented interface. for (ObjectType iface : ownerType.getCtorImplementedInterfaces()) { propType = iface.getPropertyType(propName); if (propType != null && propType.isFunctionType()) { result = propType.toMaybeFunctionType(); break; } } } if (result != null && typeMap != null && !typeMap.isEmpty()) { result = result.visit( new TemplateTypeMapReplacer(typeRegistry, typeMap)) .toMaybeFunctionType(); } return result; }
if (!restrictedObjType.getTemplateTypeMap().isEmpty() && propertyType.hasAnyTemplateTypes()) { TemplateTypeMap typeMap = restrictedObjType.getTemplateTypeMap();
= implementedInterface.getImplicitPrototype().getPropertyType(prop); TemplateTypeMap typeMap = implementedInterface.getTemplateTypeMap(); if (!typeMap.isEmpty()) { TemplateTypeMapReplacer replacer = new TemplateTypeMapReplacer( typeRegistry, typeMap);
= implementedInterface.getImplicitPrototype().getPropertyType(prop); TemplateTypeMap typeMap = implementedInterface.getTemplateTypeMap(); if (!typeMap.isEmpty()) { TemplateTypeMapReplacer replacer = new TemplateTypeMapReplacer( typeRegistry, typeMap);
TemplateTypeMap ctorTypeMap = ctorType.getTypeOfThis().getTemplateTypeMap(); if (!ctorTypeMap.isEmpty()) { superClassPropType = superClassPropType.visit( new TemplateTypeMapReplacer(typeRegistry, ctorTypeMap));
TemplateTypeMap ctorTypeMap = ctorType.getTypeOfThis().getTemplateTypeMap(); if (!ctorTypeMap.isEmpty()) { superClassPropType = superClassPropType.visit( new TemplateTypeMapReplacer(typeRegistry, ctorTypeMap));