Infer the function's return type.

@param body the body of the function.
@return the return type.
338609
protected JvmTypeReference inferFunctionReturnType(XExpression body) {
		XExpression expr = body;
		boolean stop = false;
		while (!stop && expr instanceof XBlockExpression) {
			final XBlockExpression block = (XBlockExpression) expr;
			switch (block.getExpressions().size()) {
			case 0:
				expr = null;
				break;
			case 1:
				expr = block.getExpressions().get(0);
				break;
			default:
				stop = true;
			}
		}
		if (expr == null || expr instanceof XAssignment || expr instanceof XVariableDeclaration
				|| expr instanceof SarlBreakExpression || expr instanceof SarlContinueExpression
				|| expr instanceof SarlAssertExpression) {
			return this._typeReferenceBuilder.typeRef(Void.TYPE);
		}
		return this.typeBuilder.inferredType(body);
	}
90197
public Class<?> getReturnType() {
	if (returnType == null) {
	    returnType = ClassUtil.loadClass(getReturnTypeAsString(), null);
	    if (returnType == null) initAddionalParams();
	}
	return returnType;
    }
1236206
def visit_FunctionBody(self, node):
        """"""
        for child in node.children:
            return_value = self.visit(child)

            if isinstance(child, ReturnStatement):
                return return_value

            if isinstance(child, (IfStatement, WhileStatement)):
                if return_value is not None:
                    return return_value

        return NoneType()
799121
@Override
    public boolean isReturnTypeReferenceType() {
        SignatureParser parser = new SignatureParser(getSignature());
        String returnTypeSig = parser.getReturnTypeSignature();
        return SignatureParser.isReferenceType(returnTypeSig);
    }
1153675
public static Class<?> getType(Object object) {
        Class<?> type = null;
        if (isClass(object)) {
            type = (Class<?>) object;
        } else if (object != null) {
            type = object.getClass();
        }
        return type;
    }
534757
public BufferResult getBody() {
		BufferResult b = body;
		if(b == null) return EmptyResult.getInstance();
		return b;
	}
327399
def read_body(self, body):
        
        result_spec = self.result_type.thrift_spec

        # raise application exception, if present
        for exc_spec in result_spec[1:]:
            exc = getattr(body, exc_spec[2])
            if exc is not None:
                raise exc

        # success - non-void
        if len(result_spec) >= 1 and result_spec[0] is not None:

            # value expected, but got none
            # TODO - server side should use this same logic
            if body.success is None:
                raise ValueExpectedError(
                    'Expected a value to be returned for %s, '
                    'but recieved None - only void procedures can '
                    'return None.' % self.endpoint
                )

            return body.success

        # success - void
        else:
            return None
951541
public static Type getReturnType(final String methodDescriptor) {
        char[] buf = methodDescriptor.toCharArray();
        return getType(buf, methodDescriptor.indexOf(')') + 1);
    }
1079668
function Return(type) {
    // 
    return function (target, propertyKey, descriptor) {
        if (!target.methodReturns) {
            target.methodReturns = {};
        }
        target.methodReturns[propertyKey] = type;
    };
}
694349
public static String getType(final Type t) {
        switch (t.getSort()) {
        case Type.ARRAY:
            return getType(t.getElementType());
        default:
            return t.getClassName();
        }
    }
223621
def returns(returntype):
    
    returntype = T.TypeFactory(returntype)
    def _decorator(func):
        # @returns decorator
        if U.has_fun_prop(func, "returntype"):
            raise ValueError("Cannot set return type twice")
        U.set_fun_prop(func, "returntype", returntype)
        return _wrap(func)
    return _decorator
933846
@Override
    public <T> T body(Class<T> classOfT) {
        return body(classOfT, null);
    }
767484
public <T> T getBodyJson(java.lang.reflect.Type type) {
        String str = array.toString(StandardCharsets.UTF_8);
        if (str == null || str.isEmpty()) return null;
        return context.getJsonConvert().convertFrom(type, str);
    }
568009
public static Object invoke(Class<?> returnType, String className, String methodName) {
    // If we have an explicit implementation for this method, invoke it
    if (STUB_METHODS.containsKey(new ClassAndMethod(className, methodName))) {
      return STUB_METHODS.get(new ClassAndMethod(className, methodName)).invoke();
    }

    // Otherwise return an appropriate basic type
    if (returnType == String.class) {
      return "";
    } else if (returnType == Boolean.class) {
      return false;
    } else if (returnType == Byte.class) {
      return (byte) 0;
    } else if (returnType == Character.class) {
      return (char) 0;
    } else if (returnType == Double.class) {
      return (double) 0;
    } else if (returnType == Integer.class) {
      return (int) 0;
    } else if (returnType == Float.class) {
      return (float) 0;
    } else if (returnType == Long.class) {
      return (long) 0;
    } else if (returnType == Short.class) {
      return (short) 0;
    } else {
      return Mockito.mock(returnType, new ReturnsCustomMocks());
    }
  }
717196
private static ReturnType returnType(final String s) {
        String[] args = ARGS_REGEX.split(s);
        return ReturnType.getReturnType(args[args.length - 1]);
    }
480510
public static Type getRestResponseBodyType(Type restResponseReturnType) {
        // if this type has type arguments, then we look at the last one to determine if it expects a body
        final Type[] restResponseTypeArguments = TypeUtil.getTypeArguments(restResponseReturnType);
        if (restResponseTypeArguments != null && restResponseTypeArguments.length > 0) {
            return restResponseTypeArguments[restResponseTypeArguments.length - 1];
        } else {
            // no generic type on this RestResponse sub-type, so we go up to parent
            return getRestResponseBodyType(TypeUtil.getSuperType(restResponseReturnType));
        }
    }
505861
public PactDslRequestWithoutPath body(String body, ContentType mimeType) {
        return body(body, mimeType.toString());
    }