mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant type args: check boxed types if javac would be able to compile (IDEA-53984)
This commit is contained in:
+2
@@ -20,6 +20,7 @@ import com.intellij.codeInspection.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -105,6 +106,7 @@ public class RedundantTypeArgsInspection extends GenericsInspectionToolBase {
|
||||
argumentList.getExpressions(),
|
||||
resolveResult.getSubstitutor(), expression, false);
|
||||
if (!typeArguments[i].equals(inferedType)) return;
|
||||
if (PsiUtil.resolveClassInType(method.getReturnType()) == typeParameter && PsiPrimitiveType.getUnboxedType(inferedType) != null) return;
|
||||
}
|
||||
|
||||
final PsiCallExpression copy = (PsiCallExpression)expression.copy(); //see IDEADEV-8174
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.util.*;
|
||||
class Test {
|
||||
Map someMap;
|
||||
|
||||
public int getGetBar() {
|
||||
return this.<Integer>getFoo("numberOfConfigurations");
|
||||
}
|
||||
|
||||
protected <T> T getFoo(String key) {
|
||||
return (T)someMap.get(key);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 19-Apr-2010
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.miscGenerics.RedundantTypeArgsInspection;
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
|
||||
public class RedundantTypeArgsInspectionTest extends JavaCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) {
|
||||
moduleBuilder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection/redundantTypeArgs/";
|
||||
}
|
||||
|
||||
private void doTest() throws Throwable {
|
||||
final RedundantTypeArgsInspection inspection = new RedundantTypeArgsInspection();
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.testHighlighting(true, false, false, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testReturnPrimitiveTypes() throws Throwable { // javac non-boxing: IDEA-53984
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user