change signature: don't ask about covariant overrides when types are equal, e.g. when super type is changed based on override method return type

type annotations: ensure annotations are cloned so invalidating initial type doesn't break the consequence refactoring
EA-93296 - PIEAE: PsiUtilCore.ensureValid
This commit is contained in:
Anna.Kozlova
2017-01-11 12:58:26 +01:00
parent 15dbccb971
commit 23c0f28705
4 changed files with 48 additions and 2 deletions
@@ -193,7 +193,7 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
return;
}
final PsiType overriderType = overrider.getReturnType();
if (overriderType != null && type.isAssignableFrom(overriderType)) {
if (overriderType != null && !type.equals(overriderType) && type.isAssignableFrom(overriderType)) {
covariantOverriderInfos.add(usageInfo);
}
}
@@ -58,7 +58,13 @@ public class CanonicalTypes {
protected final TypeAnnotationProvider myProvider;
public AnnotatedType(@NotNull TypeAnnotationProvider provider) {
myProvider = TypeAnnotationProvider.Static.create(provider.getAnnotations());
PsiAnnotation[] annotations = ContainerUtil.map(provider.getAnnotations(), new Function<PsiAnnotation, PsiAnnotation>() {
@Override
public PsiAnnotation fun(PsiAnnotation annotation) {
return (PsiAnnotation)annotation.copy();
}
}, PsiAnnotation.EMPTY_ARRAY);
myProvider = TypeAnnotationProvider.Static.create(annotations);
}
}
@@ -0,0 +1,20 @@
// "Make 'a.f' return 'java.util.List<java.lang.@N String>'" "true"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.List;
@Target({ElementType.TYPE_USE})
@interface N {}
class a {
List<@N String> f() {
return ;
}
}
class b extends a {
List<@N String> f() {
return null;
}
}
@@ -0,0 +1,20 @@
// "Make 'a.f' return 'java.util.List<java.lang.@N String>'" "true"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.List;
@Target({ElementType.TYPE_USE})
@interface N {}
class a {
void f() {
return ;
}
}
class b extends a {
<caret>List<@N String> f() {
return null;
}
}