ensure array is not accepted as functional interface (IDEA-172048)

This commit is contained in:
Anna.Kozlova
2017-04-28 20:23:23 +02:00
parent f964172051
commit ee750f165b
3 changed files with 12 additions and 1 deletions
@@ -112,7 +112,7 @@ public class LambdaUtil {
if (type instanceof PsiIntersectionType) {
return extractFunctionalConjunct((PsiIntersectionType)type) != null;
}
return isFunctionalClass(PsiUtil.resolveGenericsClassInType(type).getElement());
return isFunctionalClass(PsiUtil.resolveClassInClassTypeOnly(type));
}
@Contract("null -> false")
@@ -0,0 +1,10 @@
import java.util.concurrent.Callable;
class Test {
public static <T> void execute(Callable<T>[] cmds) { }
public static void main(String[] args) throws Exception{
execute(<error descr="Callable<T>[] is not a functional interface">() -> null</error>);
}
}
@@ -156,6 +156,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testNestedLambdasWithInferenceOfReturnTypeInTheLatestLambda() { doTest(); }
public void testCapturedWildcardNotOpenedDuringInference() { doTest(); }
public void testIgnoreStandaloneExpressionsInLambdaReturnForNestedCalls() { doTest(); }
public void testArrayNotAFunctionalInterface() { doTest(); }
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());