[incomplete-project-model] Attribute value must be constant: do not report on pending refs

GitOrigin-RevId: 3ea9a300b731280c6778ebcee2c858ab8b3e6534
This commit is contained in:
Tagir Valeev
2024-06-07 16:33:41 +02:00
committed by intellij-monorepo-bot
parent 49a5baff95
commit 2e03408f96
2 changed files with 5 additions and 0 deletions

View File

@@ -352,6 +352,10 @@ public final class AnnotationsHighlightUtil {
PsiElement parent = expression.getParent();
if (PsiUtil.isAnnotationMethod(parent) || parent instanceof PsiNameValuePair || parent instanceof PsiArrayInitializerMemberValue) {
if (!PsiUtil.isConstantExpression(expression)) {
if (IncompleteModelUtil.isIncompleteModel(expression) &&
IncompleteModelUtil.mayHaveUnknownTypeDueToPendingReference(expression)) {
return null;
}
String description = JavaErrorBundle.message("annotation.non.constant.attribute.value");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description);
}

View File

@@ -89,6 +89,7 @@ public class Simple {
if (<error descr="Operator '==' cannot be applied to 'char', 'boolean'">c == b</error>) {}
}
@<info descr="Not resolved until the project is fully loaded">Anno</info>(<info descr="Not resolved until the project is fully loaded">Cls</info>.<info descr="Not resolved until the project is fully loaded">CONST</info>)
void testAssign(<info descr="Not resolved until the project is fully loaded">Unknown</info> u) {
u.<info descr="Not resolved until the project is fully loaded">field</info> = 2;
}