NoObjectType(JSTypeRegistry registry) { super(registry, null, null, registry.createArrowType(null, null), null, null, true, true); getInternalArrowType().returnType = this; this.setInstanceType(this); }
NoObjectType(JSTypeRegistry registry) { super( registry, /* name= */ null, /* source= */ null, registry.createArrowType(null, null), /* typeOfThis= */ null, /* templateTypeMap= */ null, FunctionType.Kind.CONSTRUCTOR, /* nativeType= */ true, /* isAbstract= */ false); getInternalArrowType().returnType = this; this.setInstanceType(this); }
/** * Creates a constructor function type. * @param name the function's name or {@code null} to indicate that the * function is anonymous. * @param source the node defining this function. Its type * ({@link Node#getType()}) must be {@link Token#FUNCTION}. * @param parameters the function's parameters or {@code null} * to indicate that the parameter types are unknown. * @param returnType the function's return type or {@code null} to indicate * that the return type is unknown. * @param templateKeys the templatized types for the class. */ public FunctionType createConstructorType(String name, Node source, Node parameters, JSType returnType, ImmutableList<TemplateType> templateKeys) { Preconditions.checkArgument(source == null || source.isFunction()); return new FunctionType(this, name, source, createArrowType(parameters, returnType), null, createTemplateTypeMap(templateKeys, null), true, false); }
/** Create a new constructor with the parameters and return type stripped. */ public FunctionType forgetParameterAndReturnTypes() { FunctionType result = new FunctionType( registry, getReferenceName(), source, registry.createArrowType(null, null), getInstanceType(), null, true, false); result.setPrototypeBasedOn(getInstanceType()); return result; }
ErrorFunctionType(JSTypeRegistry registry, String name) { super( registry, name, null, registry.createArrowType( registry.createOptionalParameters( registry.getNativeType(ALL_TYPE), registry.getNativeType(ALL_TYPE), registry.getNativeType(ALL_TYPE)), null), null, null, true, true); // NOTE(nicksantos): Errors have the weird behavior in that they can // be called as functions, and they will return instances of themselves. // Error('x') instanceof Error => true // // In user-defined types, we would deal with this case by creating // a NamedType with the name "Error" and then resolve it later. // // For native types, we don't really want the native types to // depend on type-resolution. So we just set the return type manually // at the end of construction. // // There's similar logic in JSTypeRegistry for Array and RegExp. getInternalArrowType().returnType = getInstanceType(); } }
createArrowType(createOptionalParameters(ALL_TYPE), null), null, createTemplateTypeMap(ImmutableList.of( createArrowType( createParametersWithVarArgs(ALL_TYPE), UNKNOWN_TYPE), null, null, true, true); createArrowType(createParametersWithVarArgs(ALL_TYPE), null), null, createTemplateTypeMap(ImmutableList.of(arrayElementTemplateKey), null) createArrowType(createOptionalParameters(ALL_TYPE), BOOLEAN_TYPE), null, null, true, true); createArrowType( createOptionalParameters(UNKNOWN_TYPE, UNKNOWN_TYPE, UNKNOWN_TYPE, UNKNOWN_TYPE, UNKNOWN_TYPE, UNKNOWN_TYPE, UNKNOWN_TYPE), createArrowType(createOptionalParameters(ALL_TYPE), NUMBER_TYPE), null, null, true, true); createArrowType(createOptionalParameters(ALL_TYPE, ALL_TYPE)), null, null, true, true); REGEXP_FUNCTION_TYPE.getInternalArrowType().returnType = createArrowType(createOptionalParameters(ALL_TYPE), STRING_TYPE), null, null, true, true);
"Function", createArrowType(createParametersWithVarArgs(unknownType), unknownType),