/** Returns interfaces implemented directly by a class or its superclass. */ public final ImmutableList<ObjectType> getImplementedInterfaces() { FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor == null) { return implementedInterfaces; } ImmutableList.Builder<ObjectType> builder = ImmutableList.builder(); builder.addAll(implementedInterfaces); while (superCtor != null) { builder.addAll(superCtor.implementedInterfaces); superCtor = superCtor.getSuperClassConstructor(); } return builder.build(); }
/** Returns interfaces implemented directly by a class or its superclass. */ public Iterable<ObjectType> getImplementedInterfaces() { FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor == null) { return implementedInterfaces; } ImmutableList.Builder<ObjectType> builder = ImmutableList.builder(); builder.addAll(implementedInterfaces); while (superCtor != null) { builder.addAll(superCtor.implementedInterfaces); superCtor = superCtor.getSuperClassConstructor(); } return builder.build(); }
/** * Restricted package-accessible version of {@link #addSubType}, which ensures subtypes are not * duplicated. Generally subtypes are added internally and are guaranteed not to be duplicated, * but this has the possibility of missing unresolved supertypes (typically from externs). To * handle that case, {@link PrototypeObjectType} also adds subclasses after resolution. This * method only adds a subclass to the list if it didn't already add itself to its superclass in * the earlier pass. Ideally, "subclass" here would only refer to classes, but there's an edge * case where interfaces have the {@code Object} constructor added as its "superclass". */ final void addSubClassAfterResolution(FunctionType subClass) { checkArgument(this == subClass.getSuperClassConstructor()); if (!subClass.wasAddedToExtendedConstructorSubtypes) { addSubType(subClass); } }
public final boolean hasImplementedInterfaces() { if (!implementedInterfaces.isEmpty()) { return true; } FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor != null) { return superCtor.hasImplementedInterfaces(); } return false; }
public boolean hasImplementedInterfaces() { if (!implementedInterfaces.isEmpty()){ return true; } FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor != null) { return superCtor.hasImplementedInterfaces(); } return false; }
/** * Look for the super class implementation up the tree. */ private void recordSuperClassPrototypePropUse( FunctionType classType, String prop, Reference ref) { FunctionType superClass = classType.getSuperClassConstructor(); while (superClass != null) { if (superClass.getPrototype().hasOwnProperty(prop)) { graph.connect(getNamedContainingFunction(), ref, graph.defineNameIfNotExists( superClass.getReferenceName() + ".prototype." + prop, false)); return; } else { superClass = superClass.getSuperClassConstructor(); } } }
/** * When a class B inherits from A and A is annotated as a struct, then B automatically gets the * annotation, even if B's constructor is not explicitly annotated. */ public final boolean makesStructs() { if (!hasInstanceType()) { return false; } if (propAccess == PropAccess.STRUCT) { return true; } FunctionType superc = getSuperClassConstructor(); if (superc != null && superc.makesStructs()) { setStruct(); return true; } return false; }
/** * When a class B inherits from A and A is annotated as a dict, then B automatically gets the * annotation, even if B's constructor is not explicitly annotated. */ public final boolean makesDicts() { if (!isConstructor()) { return false; } if (propAccess == PropAccess.DICT) { return true; } FunctionType superc = getSuperClassConstructor(); if (superc != null && superc.makesDicts()) { setDict(); return true; } return false; }
/** * When a class B inherits from A and A is annotated as a dict, then B * automatically gets the annotation, even if B's constructor is not * explicitly annotated. */ public boolean makesDicts() { if (!isConstructor()) { return false; } if (propAccess == PropAccess.DICT) { return true; } FunctionType superc = getSuperClassConstructor(); if (superc != null && superc.makesDicts()) { setDict(); return true; } return false; }
/** * When a class B inherits from A and A is annotated as a struct, then B * automatically gets the annotation, even if B's constructor is not * explicitly annotated. */ public boolean makesStructs() { if (!hasInstanceType()) { return false; } if (propAccess == PropAccess.STRUCT) { return true; } FunctionType superc = getSuperClassConstructor(); if (superc != null && superc.makesStructs()) { setStruct(); return true; } return false; }
FunctionType currSuperCtor = ctorType.getSuperClassConstructor(); if (currSuperCtor == null || !currSuperCtor.isAbstract()) { return; currSuperCtor = currSuperCtor.getSuperClassConstructor();
/** * Given a constructor or an interface type and a property, finds the top-most superclass that has * the property defined (including this constructor). */ public final ObjectType getTopMostDefiningType(String propertyName) { checkState(isConstructor() || isInterface()); checkArgument(getInstanceType().hasProperty(propertyName)); FunctionType ctor = this; if (isInterface()) { return getInstanceType().getTopDefiningInterface(propertyName); } ObjectType topInstanceType = null; do { topInstanceType = ctor.getInstanceType(); ctor = ctor.getSuperClassConstructor(); } while (ctor != null && ctor.getPrototype().hasProperty(propertyName)); return topInstanceType; }
FunctionType superConstructor = getSuperClassConstructor(); if (superConstructor == null) {
/** * Given a constructor or an interface type and a property, finds the * top-most superclass that has the property defined (including this * constructor). */ public ObjectType getTopMostDefiningType(String propertyName) { Preconditions.checkState(isConstructor() || isInterface()); Preconditions.checkArgument(getInstanceType().hasProperty(propertyName)); FunctionType ctor = this; if (isInterface()) { return getTopDefiningInterface(getInstanceType(), propertyName); } ObjectType topInstanceType = null; do { topInstanceType = ctor.getInstanceType(); ctor = ctor.getSuperClassConstructor(); } while (ctor != null && ctor.getPrototype().hasProperty(propertyName)); return topInstanceType; }
@Override JSType resolveInternal(ErrorReporter reporter) { setResolvedTypeInternal(this); ObjectType implicitPrototype = getImplicitPrototype(); if (implicitPrototype != null) { implicitPrototypeFallback = (ObjectType) implicitPrototype.resolve(reporter); FunctionType ctor = getConstructor(); if (ctor != null) { FunctionType superCtor = ctor.getSuperClassConstructor(); if (superCtor != null) { // If the super ctor of this prototype object was not known before resolution, then the // subTypes would not have been set. Update them. superCtor.addSubClassAfterResolution(ctor); } } } for (Property prop : properties.values()) { prop.setType(safeResolve(prop.getType(), reporter)); } return this; }
@Override JSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> scope) { setResolvedTypeInternal(this); ObjectType implicitPrototype = getImplicitPrototype(); if (implicitPrototype != null) { implicitPrototypeFallback = (ObjectType) implicitPrototype.resolve(t, scope); FunctionType ctor = getConstructor(); if (ctor != null) { FunctionType superCtor = ctor.getSuperClassConstructor(); if (superCtor != null) { // If the super ctor of this prototype object was not known before resolution, then the // subTypes would not have been set. Update them. superCtor.addSubTypeIfNotPresent(ctor); } } } for (Property prop : properties.values()) { prop.setType(safeResolve(prop.getType(), t, scope)); } return this; }
TypedScope scopeToDeclareIn, CompilerInput input, TypedVar newVar) { FunctionType superClassCtor = fnType.getSuperClassConstructor(); Property prototypeSlot = fnType.getSlot("prototype");
FunctionType superClass = getSuperClassConstructor(); if (superClass != null) { superClass.addSubType(this);
FunctionType superClass = getSuperClassConstructor(); if (superClass != null) { superClass.addSubType(this);
FunctionType baseConstructor = functionType.getSuperClassConstructor(); if (!Objects.equals(baseConstructor, getNativeType(OBJECT_FUNCTION_TYPE)) && baseConstructor != null