mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method return type fix: when changing class params take into account super substitutor (IDEA-98145)
This commit is contained in:
+4
-2
@@ -338,14 +338,16 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
final PsiSubstitutor superClassSubstitutor =
|
||||
TypeConversionUtil.getSuperClassSubstitutor(superClass, baseClass, PsiSubstitutor.EMPTY);
|
||||
final PsiType superReturnTypeInBaseClassType = superClassSubstitutor.substitute(superReturnType);
|
||||
PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(project).getResolveHelper();
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(project).getResolveHelper();
|
||||
final PsiSubstitutor psiSubstitutor = resolveHelper.inferTypeArguments(baseClass.getTypeParameters(),
|
||||
new PsiType[]{superReturnTypeInBaseClassType},
|
||||
new PsiType[]{returnType},
|
||||
PsiUtil.getLanguageLevel(superClass));
|
||||
|
||||
final TypeMigrationRules rules = new TypeMigrationRules(TypeMigrationLabeler.getElementType(derivedClass));
|
||||
rules.setMigrationRootType(JavaPsiFacade.getElementFactory(project).createType(baseClass, psiSubstitutor));
|
||||
final PsiSubstitutor compoundSubstitutor =
|
||||
TypeConversionUtil.getSuperClassSubstitutor(superClass, derivedClass, PsiSubstitutor.EMPTY).putAll(psiSubstitutor);
|
||||
rules.setMigrationRootType(JavaPsiFacade.getElementFactory(project).createType(baseClass, compoundSubstitutor));
|
||||
rules.setBoundScope(new LocalSearchScope(derivedClass));
|
||||
TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, referenceParameterList);
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Make 'doin' return 'int'" "true"
|
||||
abstract class AsyncTask<A, B, C> {
|
||||
abstract C doin(A... a);
|
||||
}
|
||||
class AAsync extends AsyncTask<String,Integer,Integer> {
|
||||
@Override
|
||||
Integer doin(String... a) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Make 'doin' return 'int'" "true"
|
||||
abstract class AsyncTask<A, B, C> {
|
||||
abstract C doin(A... a);
|
||||
}
|
||||
class AAsync extends AsyncTask<String, Integer, Long> {
|
||||
@Override
|
||||
Long doin(String... a) {
|
||||
return <caret>1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user