@Override boolean isTheObjectType() { return getConstructor().isNativeObjectType() && "Object".equals(getReferenceName()); }
/** * If this is equal to a NamedType object, its hashCode must be equal * to the hashCode of the NamedType object. */ @Override public int hashCode() { if (hasReferenceName()) { return getReferenceName().hashCode(); } else { return super.hashCode(); } }
@Override public ObjectType getImplicitPrototype() { return getConstructor().getPrototype(); }
this.propAccess = PropAccess.ANY; this.typeOfThis = typeOfThis != null ? typeOfThis : new InstanceObjectType(registry, this, nativeType); break; case ORDINARY: case INTERFACE: this.typeOfThis = typeOfThis != null ? typeOfThis : new InstanceObjectType(registry, this, nativeType); break;
@Override public boolean isNominalType() { return hasReferenceName(); }
@Override boolean defineProperty(String name, JSType type, boolean inferred, Node propertyNode) { ObjectType proto = getImplicitPrototype(); if (proto != null && proto.hasOwnDeclaredProperty(name)) { return false; } return super.defineProperty(name, type, inferred, propertyNode); }
@Override public String getReferenceName() { return getConstructor().getReferenceName(); }
/** Creates an instance for a function that might be a constructor. */ FunctionType(JSTypeRegistry registry, String name, Node source, ArrowType arrowType, JSType typeOfThis, TemplateTypeMap templateTypeMap, boolean isConstructor, boolean nativeType) { super(registry, name, registry.getNativeObjectType(JSTypeNative.FUNCTION_INSTANCE_TYPE), nativeType, templateTypeMap); setPrettyPrint(true); Preconditions.checkArgument(source == null || Token.FUNCTION == source.getType()); Preconditions.checkNotNull(arrowType); this.source = source; if (isConstructor) { this.kind = Kind.CONSTRUCTOR; this.propAccess = PropAccess.ANY; this.typeOfThis = typeOfThis != null ? typeOfThis : new InstanceObjectType(registry, this, nativeType); } else { this.kind = Kind.ORDINARY; this.typeOfThis = typeOfThis != null ? typeOfThis : registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE); } this.call = arrowType; this.isStructuralInterface = false; }
@Override public boolean isNominalType() { return hasReferenceName(); }
@Override boolean defineProperty(String name, JSType type, boolean inferred, Node propertyNode) { ObjectType proto = getImplicitPrototype(); if (proto != null && proto.hasOwnDeclaredProperty(name)) { return false; } return super.defineProperty(name, type, inferred, propertyNode); }
@Override public boolean isBooleanObjectType() { return getConstructor().isNativeObjectType() && "Boolean".equals(getReferenceName()); }
@Override public String getReferenceName() { return getConstructor().getReferenceName(); }
/** Creates an instance for a function that is an interface. */ private FunctionType(JSTypeRegistry registry, String name, Node source, TemplateTypeMap typeParameters) { super(registry, name, registry.getNativeObjectType(JSTypeNative.FUNCTION_INSTANCE_TYPE), false, typeParameters); setPrettyPrint(true); Preconditions.checkArgument(source == null || Token.FUNCTION == source.getType()); Preconditions.checkArgument(name != null); this.source = source; this.call = new ArrowType(registry, new Node(Token.PARAM_LIST), null); this.kind = Kind.INTERFACE; this.typeOfThis = new InstanceObjectType(registry, this); this.isStructuralInterface = false; }
@Override int recursionUnsafeHashCode() { if (hasReferenceName()) { return NamedType.nominalHashCode(this); } else { return super.hashCode(); } }
@Override public boolean isNumberObjectType() { return getConstructor().isNativeObjectType() && "Number".equals(getReferenceName()); }
@Override public boolean hasReferenceName() { return getConstructor().hasReferenceName(); }
new InstanceObjectType( registry, ft, isNative, templateTypeMap.remove(constructorOnlyKeys)));
@Override public boolean isStringObjectType() { return getConstructor().isNativeObjectType() && "String".equals(getReferenceName()); }
@Override public Iterable<ObjectType> getCtorExtendedInterfaces() { return getConstructor().getExtendedInterfaces(); }
@Override public boolean isNumberObjectType() { return getConstructor().isNativeObjectType() && "Number".equals(getReferenceName()); }