java highlighting: give up check of @PolymorphicSignature methods (IDEA-251449)

GitOrigin-RevId: cf986ee46e52d6cabfc309776559481d42e6c5ce
This commit is contained in:
Anna Kozlova
2020-09-25 17:53:07 +02:00
committed by intellij-monorepo-bot
parent 3fe319cf9c
commit 636bbda18f
3 changed files with 18 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.core.JavaPsiBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.NlsContexts;
@@ -162,6 +163,12 @@ public final class PsiMethodReferenceUtil {
return false;
}
PsiElement element = result.getElement();
if (element instanceof PsiMethod &&
AnnotationUtil.isAnnotated(((PsiMethod)element), CommonClassNames.JAVA_LANG_INVOKE_MH_POLYMORPHIC, 0)) {
return true;
}
if (TypeConversionUtil.isAssignable(interfaceReturnType, methodReturnType)) {
return true;
}

View File

@@ -0,0 +1,10 @@
import java.lang.invoke.MethodHandle;
class MyTest {
private void m(MethodHandle handle) {
I stringSupplier = handle::invokeExact;
}
}
interface I {
String n() throws Throwable;
}

View File

@@ -197,6 +197,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testVoidConflict() { doTest(); }
public void testCreateMethodFromMethodRefApplicability() { doTest(); }
public void testErrorMessageOnTopCallWhenFunctionalInterfaceIsNotInferred() { doTest(); }
public void testReferencesToPolymorphicMethod() { doTest(); }
private void doTest() {
doTest(false);