void (StringBuilder builder, ExpressionContext context, final GrExpression expression) { builder.append("return "); final PsiType expectedReturnType = PsiImplUtil.inferReturnType(expression); final PsiType nnReturnType = expectedReturnType == null || PsiTypes.voidType().equals(expectedReturnType) ? TypesUtil.getJavaLangObject(expression) : expectedReturnType; GenerationUtil.wrapInCastIfNeeded(builder, nnReturnType, expression.getNominalType(), expression, context, new StatementWriter() { @Override public void writeStatement(StringBuilder builder, ExpressionContext context) { writeExpression(expression, builder, context); } }); builder.append(';'); }