PsiType () { List<GrStatement> returns = ControlFlowUtils.collectReturns(myBlock); if (returns.isEmpty()) return PsiTypes.voidType(); PsiType result = null; PsiManager manager = myBlock.getManager(); for (GrStatement returnStatement : returns) { GrExpression value = null; if (returnStatement instanceof GrReturnStatement) { value = ((GrReturnStatement)returnStatement).getReturnValue(); } else if (returnStatement instanceof GrExpression) { value = (GrExpression)returnStatement; } if (value != null) { result = TypesUtil.getLeastUpperBoundNullable(result, value.getType(), manager); } } return result; }