override/implement: do not add type parameters from super method if supercalss was erased (IDEA-142453)

This commit is contained in:
Anna Kozlova
2015-07-14 22:07:19 +03:00
parent 72cc102c0d
commit 6dddedeb39
4 changed files with 26 additions and 2 deletions
@@ -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;
}
@@ -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>
}
}
@@ -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 {