Inherit type annotations for arrays

Fixes IDEA-240571 "implement method" action works bad with arrays notnulled twice

GitOrigin-RevId: 3014f528f6af966153ae4dc8c821240fca3d9d79
This commit is contained in:
Tagir Valeev
2020-05-20 08:50:34 +00:00
committed by intellij-monorepo-bot
parent d87f515faa
commit 983a6c1d3a
4 changed files with 43 additions and 2 deletions
@@ -446,7 +446,8 @@ public class GenerateMembersUtil {
generator.addExistingName(paramName);
PsiType expressionType = GenericsUtil.getVariableTypeByExpressionType(substituted);
if (expressionType instanceof PsiArrayType && substituted instanceof PsiEllipsisType) {
expressionType = new PsiEllipsisType(((PsiArrayType)expressionType).getComponentType());
expressionType = new PsiEllipsisType(((PsiArrayType)expressionType).getComponentType())
.annotate(expressionType.getAnnotationProvider());
}
result[i] = factory.createParameter(paramName, expressionType, target);
}
@@ -321,7 +321,7 @@ public class GenericsUtil {
if (type instanceof PsiWildcardType) {
type = ((PsiWildcardType)type).getBound();
}
return type != null ? type.createArrayType() : arrayType;
return type != null ? type.createArrayType().annotate(arrayType.getAnnotationProvider()) : arrayType;
}
@Override
@@ -0,0 +1,25 @@
// "Implement methods" "true"
package org.jetbrains.annotations;
import java.lang.annotation.*;
abstract class Test {
abstract void foo(@NotNull String @NotNull[] data);
abstract void foo2(@NotNull String @NotNull ... data);
}
class TImple extends Test {
@Override
void foo(@NotNull String @NotNull [] data) {
}
@Override
void foo2(@NotNull String @NotNull ... data) {
}
}
@Target({ElementType.PARAMETER, ElementType.TYPE_USE})
@interface NotNull {}
@@ -0,0 +1,15 @@
// "Implement methods" "true"
package org.jetbrains.annotations;
import java.lang.annotation.*;
abstract class Test {
abstract void foo(@NotNull String @NotNull[] data);
abstract void foo2(@NotNull String @NotNull ... data);
}
<caret>class TImple extends Test {}
@Target({ElementType.PARAMETER, ElementType.TYPE_USE})
@interface NotNull {}