mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
unchecked generics array creation for method references
(cherry picked from commit 742ea955d1a88c4ac8cb7727a9221bdf65038c11)
This commit is contained in:
+3
@@ -88,6 +88,9 @@ public class JavaGenericsUtil {
|
||||
psiMethod.getParameterList().getParameters()[parametersCount - 1];
|
||||
final PsiType componentType = ((PsiEllipsisType)varargParameter.getType()).getComponentType();
|
||||
if (!isReifiableType(resolveResult.getSubstitutor().substitute(componentType))) {
|
||||
|
||||
if (expression instanceof PsiMethodReferenceExpression) return true;
|
||||
|
||||
final PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiCall) {
|
||||
final PsiExpressionList argumentList = ((PsiCall)parent).getArgumentList();
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
|
||||
interface I {
|
||||
Test m(List<Integer> l1, List<Integer> l2);
|
||||
}
|
||||
|
||||
static Test meth(List<Integer>... <warning descr="Parameter 'lli' is never used">lli</warning>) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Test(List<Integer>... <warning descr="Parameter 'lli' is never used">lli</warning>) {}
|
||||
|
||||
{
|
||||
I <warning descr="Variable 'i1' is never used">i1</warning> = <warning descr="Unchecked generics array creation for varargs parameter">Test::meth</warning>;
|
||||
I <warning descr="Variable 'i2' is never used">i2</warning> = <warning descr="Unchecked generics array creation for varargs parameter">Test::new</warning>;
|
||||
}
|
||||
}
|
||||
+6
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
@@ -31,6 +32,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{
|
||||
new UnusedSymbolLocalInspection(),
|
||||
new UncheckedWarningLocalInspection()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,6 +84,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testGenericArrayCreation() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user