mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant type args: process nested calls (IDEA-117945)
This commit is contained in:
+6
-2
@@ -74,14 +74,18 @@ public class RedundantTypeArgsInspection extends GenericsInspectionToolBase {
|
||||
public ProblemDescriptor[] getDescriptions(@NotNull PsiElement place, @NotNull final InspectionManager inspectionManager, boolean isOnTheFly) {
|
||||
final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
|
||||
place.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
super.visitMethodCallExpression(expression);
|
||||
final PsiType[] typeArguments = expression.getTypeArguments();
|
||||
if (typeArguments.length > 0) {
|
||||
checkCallExpression(expression.getMethodExpression(), typeArguments, expression, inspectionManager, problems);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitNewExpression(PsiNewExpression expression) {
|
||||
@Override
|
||||
public void visitNewExpression(PsiNewExpression expression) {
|
||||
super.visitNewExpression(expression);
|
||||
final PsiType[] typeArguments = expression.getTypeArguments();
|
||||
if (typeArguments.length > 0) {
|
||||
final PsiJavaCodeReferenceElement classReference = expression.getClassReference();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import java.io.Serializable;
|
||||
|
||||
final class Expected {
|
||||
public static <P extends Serializable> Expected make(final P good) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Serializer {
|
||||
<T> T deserialize(final Class<T> type);
|
||||
}
|
||||
|
||||
class FooBar {
|
||||
<T extends Serializable> void invoke(final Class<T> rpc, final Serializer serializer) {
|
||||
Expected.make(serializer.<warning descr="Explicit type arguments can be inferred"><T></warning>deserialize(rpc));
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -37,4 +37,8 @@ public class RedundantTypeArgsInspectionTest extends JavaCodeInsightFixtureTestC
|
||||
public void testBoundInference() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNestedCalls() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user