From 46bbf55acdd029a4393b481c6cc75907f1d7d471 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 7 Aug 2017 21:02:01 +0300 Subject: [PATCH] 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 --- .../load/java/structure/impl/annotationArgumentsImpl.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt index 81b364fca31..20419fad2a3 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt @@ -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) } }