java deprecation: don't highlight lambda if target functional interface is deprecated (IDEA-246336)

javac doesn't report such cases and most probably method with functional interface must be deprecated as well, so deprecation would be visible; otherwise too much code would be crossed out

GitOrigin-RevId: b75feb5a4052d6da9355bda1f37374c66d964b29
This commit is contained in:
Anna Kozlova
2020-07-22 08:45:41 +02:00
committed by intellij-monorepo-bot
parent e3f4941ffe
commit 5fcbd6cb28
3 changed files with 20 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ public final class DeprecatedApiUsageProcessor implements ApiUsageProcessor {
@Override
public void processReference(@NotNull UElement sourceNode, @NotNull PsiModifierListOwner target, @Nullable UExpression qualifier) {
if (sourceNode instanceof ULambdaExpression) return;
checkTargetDeprecated(sourceNode, target);
}

View File

@@ -0,0 +1,14 @@
@Deprecated
interface I {
void m();
}
class Util {
@Deprecated
static void foo(I i) {}
}
class MyTest {
{
Util.<warning descr="'foo(I)' is deprecated">foo</warning>(() -> {});
}
}

View File

@@ -18,6 +18,7 @@ package com.intellij.java.codeInsight.daemon;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.compiler.JavacQuirksInspection;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.deprecation.DeprecationInspection;
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.pom.java.LanguageLevel;
@@ -54,4 +55,8 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase {
public void testNoArraySuperType() { doTest(true, true);}
public void testCaptureItself() { doTest(true, true); }
public void testNestedConditionalWithOverloads() { doTest(true, true); }
public void testDeprecatedFunctionalInterface() {
enableInspectionTool(new DeprecationInspection());
doTest(true, true);
}
}