PsiTypesUtil: reverted erroneous changes in getExpectedTypeByParent (IDEA-CR-15590)
[idea/community.git] / java / java-psi-api / src / com / intellij / psi / util / PsiTypesUtil.java
index bec5aaf8d116a329b131b20a96aaab44d5924dcf..0abcca03ea5d7f4ea2c24f204d5c5c61d03432c8 100644 (file)
@@ -211,7 +211,13 @@ public class PsiTypesUtil {
       }
     }
     else if (parent instanceof PsiReturnStatement) {
-      return getMethodReturnType(parent);
+      final PsiElement psiElement = PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class, PsiMethod.class);
+      if (psiElement instanceof PsiLambdaExpression) {
+        return null;
+      }
+      else if (psiElement instanceof PsiMethod){
+        return ((PsiMethod)psiElement).getReturnType();
+      }
     }
     else if (PsiUtil.isCondition(element, parent)) {
       return PsiType.BOOLEAN.getBoxedType(parent);
@@ -231,7 +237,7 @@ public class PsiTypesUtil {
         }
       }
       else if (gParent instanceof PsiArrayInitializerExpression) {
-        final PsiType expectedTypeByParent = getExpectedTypeByParent((PsiExpression)parent);
+        final PsiType expectedTypeByParent = getExpectedTypeByParent(parent);
         return expectedTypeByParent != null && expectedTypeByParent instanceof PsiArrayType
                ? ((PsiArrayType)expectedTypeByParent).getComponentType() : null;
       }