mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inheritance 2 delegation: type parameters substitution (IDEA-53529)
This commit is contained in:
+3
-1
@@ -384,7 +384,9 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
if (!myIsInnerClassNeeded) return;
|
||||
|
||||
PsiClass innerClass = myFactory.createClass(myInnerClassName);
|
||||
final PsiJavaCodeReferenceElement baseClassReferenceElement = myFactory.createClassReferenceElement(myBaseClass);
|
||||
final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(myBaseClass, myClass, PsiSubstitutor.EMPTY);
|
||||
final PsiClassType superClassType = myFactory.createType(myBaseClass, superClassSubstitutor);
|
||||
final PsiJavaCodeReferenceElement baseClassReferenceElement = myFactory.createReferenceElementByType(superClassType);
|
||||
if (!myBaseClass.isInterface()) {
|
||||
innerClass.getExtendsList().add(baseClassReferenceElement);
|
||||
} else {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class A {
|
||||
public final MyIntf myDelegate = new MyIntf();
|
||||
|
||||
private class MyIntf implements Intf<Integer> {
|
||||
public void method1(Integer t) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public interface Intf<T> {
|
||||
void method1(T t);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
public class A implements Intf<Integer> {
|
||||
public void method1(Integer t) {
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public interface Intf<T> {
|
||||
void method1(T t);
|
||||
}
|
||||
@@ -119,6 +119,9 @@ public class InheritanceToDelegationTest extends MultiFileTestCase {
|
||||
new String[]{"getDate"}, ArrayUtil.EMPTY_STRING_ARRAY, false, false));
|
||||
}
|
||||
|
||||
public void testTypeParametersSubstitution() throws Exception {
|
||||
doTest(createPerformAction("A", "myDelegate", "MyIntf", "Intf", new int[]{}, ArrayUtil.EMPTY_STRING_ARRAY, true, false));
|
||||
}
|
||||
|
||||
private PerformAction createPerformAction(
|
||||
final String className, final String fieldName, final String innerClassName,
|
||||
|
||||
Reference in New Issue
Block a user