PsiTypesUtil: reverted erroneous changes in getExpectedTypeByParent (IDEA-CR-15590)
authorTagir Valeev <Tagir.Valeev@jetbrains.com>
Fri, 11 Nov 2016 10:18:08 +0000 (17:18 +0700)
committerTagir Valeev <Tagir.Valeev@jetbrains.com>
Fri, 11 Nov 2016 10:19:40 +0000 (17:19 +0700)
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) {
       }
     }
     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);
     }
     else if (PsiUtil.isCondition(element, parent)) {
       return PsiType.BOOLEAN.getBoxedType(parent);
@@ -231,7 +237,7 @@ public class PsiTypesUtil {
         }
       }
       else if (gParent instanceof PsiArrayInitializerExpression) {
         }
       }
       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;
       }
         return expectedTypeByParent != null && expectedTypeByParent instanceof PsiArrayType
                ? ((PsiArrayType)expectedTypeByParent).getComponentType() : null;
       }