mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplify ? extends Object (IDEA-91631; IDEA-91144)
This commit is contained in:
@@ -258,6 +258,7 @@ public class GenericsUtil {
|
||||
if (((PsiWildcardType)acceptedBound).isExtends() != wildcardType.isExtends()) return PsiWildcardType.createUnbounded(manager);
|
||||
return acceptedBound;
|
||||
}
|
||||
if (wildcardType.isExtends() && acceptedBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) return PsiWildcardType.createUnbounded(manager);
|
||||
if (acceptedBound.equals(bound)) return wildcardType;
|
||||
return wildcardType.isExtends()
|
||||
? PsiWildcardType.createExtends(manager, acceptedBound)
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
interface Generic<T> {
|
||||
SomeGeneric<? extends T> foo();
|
||||
}
|
||||
|
||||
class II implements Generic<Object> {
|
||||
public SomeGeneric<?> foo() {
|
||||
<selection>return null; //To change body of implemented methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
|
||||
class SomeGeneric<P> {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
interface Generic<T> {
|
||||
SomeGeneric<? extends T> foo();
|
||||
}
|
||||
|
||||
class II implements Generic<Object> {
|
||||
<caret>
|
||||
}
|
||||
|
||||
class SomeGeneric<P> {
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.util.*;
|
||||
public class IntroduceParameterProducesWarning {
|
||||
private final List<Generic<?>> elements;
|
||||
|
||||
public IntroduceParameterProducesWarning(final ArrayList<Generic<?>> anObject) {
|
||||
elements = anObject;
|
||||
}
|
||||
|
||||
public static <E> ArrayList<E> newArrayList(E... elements) {
|
||||
ArrayList<E> list = new ArrayList<E>();
|
||||
Collections.addAll(list, elements);
|
||||
return list;
|
||||
}
|
||||
|
||||
private static interface Generic<T>{
|
||||
|
||||
}
|
||||
|
||||
private static class SomeGeneric implements Generic<String> {
|
||||
}
|
||||
|
||||
private static class SomeOtherGeneric implements Generic<Object> {
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.util.*;
|
||||
public class IntroduceParameterProducesWarning {
|
||||
private final List<Generic<?>> elements;
|
||||
|
||||
public IntroduceParameterProducesWarning() {
|
||||
elements = <selection>newArrayList(new SomeGeneric(), new SomeOtherGeneric())</selection>;
|
||||
}
|
||||
|
||||
public static <E> ArrayList<E> newArrayList(E... elements) {
|
||||
ArrayList<E> list = new ArrayList<E>();
|
||||
Collections.addAll(list, elements);
|
||||
return list;
|
||||
}
|
||||
|
||||
private static interface Generic<T>{
|
||||
|
||||
}
|
||||
|
||||
private static class SomeGeneric implements Generic<String> {
|
||||
}
|
||||
|
||||
private static class SomeOtherGeneric implements Generic<Object> {
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
public void testSubstituteBoundInMethodTypeParam() { doTest(false); }
|
||||
public void testClone() { doTest(false); }
|
||||
public void testOnTheLineWithExistingExpression() { doTest(false); }
|
||||
public void testSimplifyObjectWildcard() { doTest(false); }
|
||||
|
||||
public void testImplementExtensionMethods() { doTest8(false, true); }
|
||||
public void testDoNotImplementExtensionMethods() { doTest8(false, true); }
|
||||
|
||||
@@ -313,6 +313,10 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
public void testSimplifiedResultedType() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
private void doTestThroughHandler() throws Exception {
|
||||
configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
|
||||
boolean enabled = true;
|
||||
|
||||
Reference in New Issue
Block a user