/** Returns the type of the getter, falling back on unknown if the return type was inferred. */ private JSType determineGetterType(FunctionType methodType) { // TODO(sdh): consider only falling back on unknown if the function body is empty? But we // need to not report a conflicting type error if there's different unknowns. return !methodType.isReturnTypeInferred() ? methodType.getReturnType() : unknownType; } } // end ClassScopeBuilder
/** * If a variable is assigned a function literal in the global scope, * make that a declared type (even if there's no doc info). * There's only one exception to this rule: * if the return type is inferred, and we're in a local * scope, we should assume the whole function is inferred. */ private boolean shouldUseFunctionLiteralType( FunctionType type, JSDocInfo info, Node lValue) { if (info != null) { return true; } if (lValue != null && NodeUtil.mayBeObjectLitKey(lValue)) { return false; } // TODO(johnlenz): consider unifying global and local behavior return isLValueRootedInGlobalScope(lValue) || !type.isReturnTypeInferred(); }
/** * If a variable is assigned a function literal in the global scope, * make that a declared type (even if there's no doc info). * There's only one exception to this rule: * if the return type is inferred, and we're in a local * scope, we should assume the whole function is inferred. */ private boolean shouldUseFunctionLiteralType( FunctionType type, JSDocInfo info, Node lValue) { if (info != null) { return true; } if (lValue != null && NodeUtil.isObjectLitKey(lValue)) { return false; } return scope.isGlobal() || !type.isReturnTypeInferred(); }
/** Copies all the information from another function type. */ public FunctionBuilder copyFromOtherFunction(FunctionType otherType) { int isNative = otherType.isNativeObjectType() ? IS_NATIVE : 0; int isAbstract = otherType.isAbstract() ? IS_ABSTRACT : 0; int inferredReturnType = otherType.isReturnTypeInferred() ? INFERRED_RETURN_TYPE : 0; this.name = otherType.getReferenceName(); this.sourceNode = otherType.getSource(); this.parametersNode = otherType.getParametersNode(); this.returnType = otherType.getReturnType(); this.typeOfThis = otherType.getTypeOfThis(); this.templateTypeMap = otherType.getTemplateTypeMap(); this.kind = otherType.getKind(); this.properties = isNative | isAbstract | inferredReturnType; return this; }
returnTypeInferred = oldType.isReturnTypeInferred(); if (paramsParent == null) {
returnTypeInferred = oldType.isReturnTypeInferred(); if (paramsParent == null) {