PsiType (GrMethodCall methodCall, PsiMethod method) { GrExpression[] allArguments = PsiUtil.getAllArguments(methodCall); GrClosableBlock closure = null; for (GrExpression argument : allArguments) { if (argument instanceof GrClosableBlock) { closure = (GrClosableBlock)argument; break; } } if (closure == null) return null; final GrClosableBlock finalClosure = closure; return RecursionManager.doPreventingRecursion(methodCall, true, () -> { PsiType returnType = finalClosure.getReturnType(); if (PsiTypes.voidType().equals(returnType)) return null; return returnType; }); }