From 33f7cb51f22b336d497c0a7652804af9e1b49915 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 4 Sep 2014 12:51:50 +0400 Subject: [PATCH 1/2] new inference: most specific check according to spec, fixed testdata after JDK-8043734 --- .../source/resolve/graphInference/InferenceSession.java | 7 ------- .../daemonCodeAnalyzer/lambda/highlighting/Ambiguity1.java | 2 +- .../lambda/highlighting/AmbiguityRawGenerics.java | 2 +- .../NoReturnTypeResolutionForThrownException.java | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index e3c6d2341dc8..d93b7565c988 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -1205,9 +1205,6 @@ public class InferenceSession { } final List returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg); - if (sReturnType == PsiType.VOID) { - return returnExpressions.isEmpty() && session == null; - } if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) && !TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(sReturnType), TypeConversionUtil.erasure(tReturnType)) && @@ -1263,10 +1260,6 @@ public class InferenceSession { return true; } - if (sReturnType == PsiType.VOID && session != null) { - return false; - } - final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID; final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Ambiguity1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Ambiguity1.java index e66630146e6f..02bbebd074b0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Ambiguity1.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Ambiguity1.java @@ -12,7 +12,7 @@ class Ambiguity1 { static void m(I2 i2) {} { - m(()->{throw new AssertionError();}); + m(()->{throw new AssertionError();}); m(() -> {}); m(() -> { if (false) return; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java index 595787704437..6c664dd9e65a 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java @@ -22,6 +22,6 @@ class AmbiguityRawGenerics { void foo(I3 s) { } void bar() { - foo(()-> { throw new RuntimeException(); }); + foo(()-> { throw new RuntimeException(); }); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NoReturnTypeResolutionForThrownException.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NoReturnTypeResolutionForThrownException.java index 81429131d099..1fe14f680abe 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NoReturnTypeResolutionForThrownException.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NoReturnTypeResolutionForThrownException.java @@ -7,7 +7,7 @@ class Test { void call(I2 p) { } void test() { - call(() -> { throw new RuntimeException(); }); + call(() -> { throw new RuntimeException(); }); call(() -> { if (true) return ""; throw new RuntimeException(); }); call(() -> { if (true) return; throw new RuntimeException(); }); } From 041f4d6e348647d6b04735d90c61298deb269ce4 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 4 Sep 2014 13:42:45 +0400 Subject: [PATCH 2/2] EA-60119 - IAE: PsiCapturedWildcardType.create --- java/java-psi-api/src/com/intellij/psi/GenericsUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java index c835a4171f74..4646aea635b3 100644 --- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java @@ -262,7 +262,9 @@ public class GenericsUtil { for (PsiTypeParameter typeParameter : typeParams) { PsiType substituted = substitutor.substitute(typeParameter); if (substituted == null) return null; - substituted = PsiUtil.captureToplevelWildcards(substituted, context); + if (context != null) { + substituted = PsiUtil.captureToplevelWildcards(substituted, context); + } PsiClassType[] extendsTypes = typeParameter.getExtendsListTypes(); for (PsiClassType type : extendsTypes) {