From 64fb114c30e15190e7e2756b5ae0629a8813eb25 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 5 Oct 2020 15:58:23 +0300 Subject: [PATCH] FIR Java annotations: create vararg or Array depending on parameter name #KT-42346 Fixed --- .../analysis-tests/testData/resolve/problems/kt42346.txt | 2 +- .../src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/kt42346.txt b/compiler/fir/analysis-tests/testData/resolve/problems/kt42346.txt index 0d3fd08d077..412aebf6d84 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/kt42346.txt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/kt42346.txt @@ -21,7 +21,7 @@ FILE: kt42346.kt } } - @R|MagicConstant|(vararg(intValues = (Q|StepRequest|.R|/StepRequest.Companion.STEP_INTO|.R|kotlin/Int.toLong|(), Q|StepRequest|.R|/StepRequest.Companion.STEP_OVER|.R|kotlin/Int.toLong|(), Q|StepRequest|.R|/StepRequest.Companion.STEP_OUT|.R|kotlin/Int.toLong|()))) public final val depth: R|kotlin/Int| = Int(42) + @R|MagicConstant|(intValues = (Q|StepRequest|.R|/StepRequest.Companion.STEP_INTO|.R|kotlin/Int.toLong|(), Q|StepRequest|.R|/StepRequest.Companion.STEP_OVER|.R|kotlin/Int.toLong|(), Q|StepRequest|.R|/StepRequest.Companion.STEP_OUT|.R|kotlin/Int.toLong|())) public final val depth: R|kotlin/Int| = Int(42) public get(): R|kotlin/Int| public final annotation class KotlinMagicConstant : R|kotlin/Annotation| { public constructor(intValues: R|kotlin/LongArray|): R|KotlinMagicConstant| { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index b221900a51c..d11f8581b78 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -369,13 +369,13 @@ class JavaSymbolProvider( val parameterForAnnotationConstructor = buildJavaValueParameter { session = this@JavaSymbolProvider.session returnTypeRef = firJavaMethod.returnTypeRef - name = firJavaMethod.name + name = methodName if (javaMethod.hasAnnotationParameterDefaultValue) { defaultValue = buildExpressionStub() } - isVararg = javaMethod.returnType is JavaArrayType + isVararg = returnType is JavaArrayType && methodName == VALUE_METHOD_NAME } - if (firJavaMethod.name == VALUE_METHOD_NAME) { + if (methodName == VALUE_METHOD_NAME) { valueParametersForAnnotationConstructor.valueParameterForValue = parameterForAnnotationConstructor } else { valueParametersForAnnotationConstructor.valueParameters += parameterForAnnotationConstructor