Special value for class literal expression

Starting from Idea 172 evaluator gives non-null value for class literal
expression. Probably behaviour was changed in

https://github.com/JetBrains/intellij-community/commit/65ddb4c454110190b8d7374f1f3058ec03a59c5e
This commit is contained in:
Nikolay Krasko
2017-08-07 21:02:01 +03:00
parent eeede71d9d
commit 46bbf55acd
@@ -25,10 +25,15 @@ abstract class JavaAnnotationArgumentImpl(
) : JavaAnnotationArgument {
companion object Factory {
fun create(argument: PsiAnnotationMemberValue, name: Name?): JavaAnnotationArgument {
if (argument is PsiClassObjectAccessExpression) {
return JavaClassObjectAnnotationArgumentImpl(argument, name)
}
val value = JavaPsiFacade.getInstance(argument.project).constantEvaluationHelper.computeConstantExpression(argument)
if (value is Enum<*>) {
return JavaEnumValueAnnotationArgumentImpl(argument as PsiReferenceExpression, name)
}
if (value != null || argument is PsiLiteralExpression) {
return JavaLiteralAnnotationArgumentImpl(name, value)
}
@@ -37,7 +42,6 @@ abstract class JavaAnnotationArgumentImpl(
is PsiReferenceExpression -> JavaEnumValueAnnotationArgumentImpl(argument, name)
is PsiArrayInitializerMemberValue -> JavaArrayAnnotationArgumentImpl(argument, name)
is PsiAnnotation -> JavaAnnotationAsAnnotationArgumentImpl(argument, name)
is PsiClassObjectAccessExpression -> JavaClassObjectAnnotationArgumentImpl(argument, name)
else -> throw UnsupportedOperationException("Unsupported annotation argument type: " + argument)
}
}