boolean (@NotNull KtDeclaration functionOrGetter, @NotNull KtExpression expression) { if (functionOrGetter instanceof KtFunctionLiteral) { KtBlockExpression functionLiteralBody = ((KtFunctionLiteral) functionOrGetter).getBodyExpression(); PsiElement returnedElement = null; if (functionLiteralBody != null) { PsiElement[] children = functionLiteralBody.getChildren(); int length = children.length; if (length > 0) { returnedElement = children[length - 1]; } } return returnedElement instanceof KtExpression && canEvaluateTo((KtExpression) returnedElement, expression); } else { if (functionOrGetter instanceof KtDeclarationWithInitializer && canEvaluateTo(((KtDeclarationWithInitializer) functionOrGetter).getInitializer(), expression)) { return true; } KtReturnExpression returnExpression = PsiTreeUtil.getParentOfType(expression, KtReturnExpression.class); return returnExpression != null && canEvaluateTo(returnExpression.getReturnedExpression(), expression); } }