checked exception constraints: ensure ground type (IDEA-173200)

This commit is contained in:
Anna Kozlova
2017-05-22 11:20:51 +03:00
parent 8ae9ee00bb
commit 011b8e4e10
3 changed files with 21 additions and 2 deletions

View File

@@ -17,7 +17,6 @@ package com.intellij.psi.impl.source.resolve.graphInference.constraints;
import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
@@ -76,7 +75,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
return false;
}
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, PsiUtil.resolveGenericsClassInType(myT));
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, PsiUtil.resolveGenericsClassInType(groundTargetType));
if (myExpression instanceof PsiLambdaExpression && !((PsiLambdaExpression)myExpression).hasFormalParameterTypes() ||
myExpression instanceof PsiMethodReferenceExpression && !((PsiMethodReferenceExpression)myExpression).isExact()) {
for (PsiParameter parameter : interfaceMethod.getParameterList().getParameters()) {

View File

@@ -0,0 +1,19 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.function.Function;
class Main {
public static void main(String[] args) {
runTest(Main::test, UncheckedIOException:: new);
}
private static void test() throws IOException {}
private static <E extends Throwable> void runTest(A<? extends E> a, Function<E, ?> b) { }
@FunctionalInterface
public interface A<E extends Throwable> {
void foo() throws E;
}
}

View File

@@ -173,6 +173,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testMethodREfToContainingMethodWithGenericParam() { doTest(); }
public void testDistinguishCapturedWildcardsByDifferentParameters() throws Exception { doTest(); }
public void testConstructorRefOnClassWithRecursiveTypeParameter() throws Exception { doTest(); }
public void testWildcardInCheckedCompatibilityConstraints() { doTest(); }
public void testPreferErrorOnTopLevelToFailedSubstitutorOnNestedLevel() { doTest(); }