mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
override/implement: do not add type parameters from super method if supercalss was erased (IDEA-142453)
This commit is contained in:
@@ -312,7 +312,7 @@ public class GenerateMembersUtil {
|
||||
@Nullable PsiTypeParameterList targetTypeParameterList,
|
||||
@NotNull PsiSubstitutor substitutor,
|
||||
@NotNull PsiMethod sourceMethod) {
|
||||
if (sourceTypeParameterList == null || targetTypeParameterList == null) {
|
||||
if (sourceTypeParameterList == null || targetTypeParameterList == null || PsiUtil.isRawSubstitutor(sourceMethod, substitutor)) {
|
||||
return substitutor;
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Foo<T> {
|
||||
<S> S foo(T foo) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar<S> extends Foo {
|
||||
@Override
|
||||
Object foo(Object foo) {
|
||||
<selection>return super.foo(foo);</selection>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo<T> {
|
||||
<S> S foo(T foo) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar<S> extends Foo {
|
||||
<caret>
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.generation.JavaOverrideMethodsHandler;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.codeInsight.generation.PsiMethodMember;
|
||||
import com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler;
|
||||
@@ -68,6 +69,7 @@ public class OverrideImplement15Test extends LightCodeInsightTestCase {
|
||||
public void testMultipleInterfaceInheritance() { doTest(false); }
|
||||
public void testResolveTypeParamConflict() { doTest(false); }
|
||||
public void testRawInheritance() { doTest(false); }
|
||||
public void testRawInheritanceWithMethodTypeParameters() { doTest(false); }
|
||||
|
||||
public void testLongFinalParameterList() {
|
||||
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
|
||||
@@ -156,7 +158,8 @@ public class OverrideImplement15Test extends LightCodeInsightTestCase {
|
||||
assert superClass != null;
|
||||
PsiMethod method = superClass.getMethods()[0];
|
||||
final PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, psiClass, PsiSubstitutor.EMPTY);
|
||||
final List<PsiMethodMember> candidates = Collections.singletonList(new PsiMethodMember(method, substitutor));
|
||||
final List<PsiMethodMember> candidates = Collections.singletonList(new PsiMethodMember(method,
|
||||
OverrideImplementExploreUtil.correctSubstitutor(method, substitutor)));
|
||||
OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(getEditor(), psiClass, candidates, copyJavadoc, true);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user