/** Infer the return type for the given source function. * * @param source the source function. * @param target the target operation. * @param overriddenOperation reference to the overridden operation. * @return the inferred return type. * @since 0.7 */ protected JvmTypeReference inferFunctionReturnType(XtendFunction source, JvmOperation target, JvmOperation overriddenOperation) { // The return type is explicitly given if (source.getReturnType() != null) { return ensureValidType(source.eResource(), source.getReturnType()); } // An super operation was detected => reuse its return type. if (overriddenOperation != null) { final JvmTypeReference type = overriddenOperation.getReturnType(); //return cloneWithProxiesFromOtherResource(type, target); return this.typeReferences.createDelegateTypeReference(type); } // Return type is inferred from the operation's expression. final XExpression expression = source.getExpression(); JvmTypeReference returnType = null; if (expression != null && ((!(expression instanceof XBlockExpression)) || (!((XBlockExpression) expression).getExpressions().isEmpty()))) { returnType = inferFunctionReturnType(expression); } return ensureValidType(source.eResource(), returnType); }
final JvmTypeReference selectedReturnType = inferFunctionReturnType(source, operation, inheritedOperation); operation.setReturnType(selectedReturnType);