diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inliner/SimpleMethodInliner.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inliner/SimpleMethodInliner.java index 9cd75ce8b7fe..3595a81c56c3 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inliner/SimpleMethodInliner.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inliner/SimpleMethodInliner.java @@ -48,7 +48,9 @@ public class SimpleMethodInliner implements CallInliner { boolean allowed = PsiTreeUtil.processElements(value, e -> { if (!(e instanceof PsiExpression)) return true; if (e instanceof PsiInstanceOfExpression || e instanceof PsiParenthesizedExpression || e instanceof PsiLiteralExpression || - e instanceof PsiPolyadicExpression || e instanceof PsiUnaryExpression || e instanceof PsiConditionalExpression) { + e instanceof PsiPolyadicExpression || e instanceof PsiUnaryExpression || e instanceof PsiConditionalExpression || + e instanceof PsiTypeCastExpression || e instanceof PsiArrayAccessExpression || e instanceof PsiLambdaExpression || + e instanceof PsiMethodReferenceExpression) { return true; } if (e instanceof PsiReferenceExpression) { diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/InlineSimpleMethods.java b/java/java-tests/testData/inspection/dataFlow/fixture/InlineSimpleMethods.java index 48eaf10fe0f4..8936d6006137 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/InlineSimpleMethods.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/InlineSimpleMethods.java @@ -32,4 +32,24 @@ class Scratch { private boolean hasData() { return data != null && data.length > 0; } + + int[] array; + + private int readValue() { + return array[0]; + } + + void testArraySize() { + if(readValue() > 0 && array.length > 0) {} + } + + Object element; + + private String getString() { + return ((String)element); + } + + void testGetString() { + if(!getString().isEmpty() && element instanceof String) {} + } } \ No newline at end of file