java inference: stop walkUp in assignment context inside method call chain (IDEA-217928)

GitOrigin-RevId: 79ac2370cd302d7e38d029e065ff4a28ed8709a4
This commit is contained in:
Anna Kozlova
2019-07-11 21:10:04 +02:00
committed by intellij-monorepo-bot
parent 6ebf3349dc
commit bd882f2a97
3 changed files with 23 additions and 1 deletions

View File

@@ -752,7 +752,8 @@ public class LambdaUtil {
break;
}
final PsiCall psiCall = PsiTreeUtil.getParentOfType(parent, PsiCall.class, false, PsiMember.class, PsiVariable.class);
final PsiCall psiCall = PsiTreeUtil.getParentOfType(parent, PsiCall.class, false, PsiMember.class, PsiVariable.class,
PsiAssignmentExpression.class, PsiTypeCastExpression.class);
if (psiCall == null) {
break;
}

View File

@@ -0,0 +1,20 @@
import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class MyTest {
void foo(Stream<Map.Entry<Object, Object>> stream) {
Supplier<Map<Object, Object>> s = null;
(s = () -> stream
.collect(Collectors.toMap(
entry -> entry.getKey(),
Map.Entry::getValue
))).get();
((Supplier<Map<Object, Object>>) () -> stream
.collect(Collectors.toMap(
entry -> entry.getKey(),
Map.Entry::getValue
))).get();
}
}

View File

@@ -169,6 +169,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testFunctionalBound() { doTest(); }
public void testValidFixesOnUnresolvedMethod() { doTest(); }
public void testPolyExpressionInVoidCompatibleLambdaReturn() { doTest(); }
public void testStopAtTypeCastWhenSearchForTopMostNode() { doTest(); }
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());