diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 22832306721..9aff880f081 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -821,14 +821,13 @@ internal class DescriptorRendererImpl( renderModifier(builder, valueParameter.isCrossinline, "crossinline") renderModifier(builder, valueParameter.isNoinline, "noinline") - if (renderPrimaryConstructorParametersAsProperties && - (valueParameter.containingDeclaration as? ClassConstructorDescriptor)?.isPrimary == true - ) { + val isPrimaryConstructor = renderPrimaryConstructorParametersAsProperties && + (valueParameter.containingDeclaration as? ClassConstructorDescriptor)?.isPrimary == true + if (isPrimaryConstructor) { renderModifier(builder, actualPropertiesInPrimaryConstructor, "actual") - renderModifier(builder, true, "val") } - renderVariable(valueParameter, includeName, builder, topLevel) + renderVariable(valueParameter, includeName, builder, topLevel, isPrimaryConstructor) val withDefaultValue = defaultParameterValueRenderer != null && @@ -838,21 +837,27 @@ internal class DescriptorRendererImpl( } } - private fun renderValVarPrefix(variable: VariableDescriptor, builder: StringBuilder) { - if (variable !is ValueParameterDescriptor) { + private fun renderValVarPrefix(variable: VariableDescriptor, builder: StringBuilder, isInPrimaryConstructor: Boolean = false) { + if (isInPrimaryConstructor || variable !is ValueParameterDescriptor) { builder.append(renderKeyword(if (variable.isVar) "var" else "val")).append(" ") } } - private fun renderVariable(variable: VariableDescriptor, includeName: Boolean, builder: StringBuilder, topLevel: Boolean) { + private fun renderVariable( + variable: VariableDescriptor, + includeName: Boolean, + builder: StringBuilder, + topLevel: Boolean, + isInPrimaryConstructor: Boolean = false + ) { val realType = variable.type val varargElementType = (variable as? ValueParameterDescriptor)?.varargElementType val typeToRender = varargElementType ?: realType - renderModifier(builder, varargElementType != null, "vararg") - if (topLevel && !startFromName) { - renderValVarPrefix(variable, builder) + + if (isInPrimaryConstructor || topLevel && !startFromName) { + renderValVarPrefix(variable, builder, isInPrimaryConstructor) } if (includeName) { diff --git a/idea/testData/multiModuleQuickFix/expectClassWithVararg/header/My.kt b/idea/testData/multiModuleQuickFix/expectClassWithVararg/header/My.kt new file mode 100644 index 00000000000..e8182b18100 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/expectClassWithVararg/header/My.kt @@ -0,0 +1,2 @@ +// My: to be implemented +// DISABLE-ERRORS \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/expectClassWithVararg/header/My.kt.after b/idea/testData/multiModuleQuickFix/expectClassWithVararg/header/My.kt.after new file mode 100644 index 00000000000..8909f519d4a --- /dev/null +++ b/idea/testData/multiModuleQuickFix/expectClassWithVararg/header/My.kt.after @@ -0,0 +1,3 @@ +// My: to be implemented +// DISABLE-ERRORS +expect annotation class My(vararg val arg: String) \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/expectClassWithVararg/jvm/My.kt b/idea/testData/multiModuleQuickFix/expectClassWithVararg/jvm/My.kt new file mode 100644 index 00000000000..7c40b4125d3 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/expectClassWithVararg/jvm/My.kt @@ -0,0 +1,4 @@ +// "Create expected annotation class in common module testModule_Common" "true" +// DISABLE-ERRORS + +actual annotation class My actual constructor(actual vararg val arg: String) \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/expectClassWithVararg/jvm/My.kt.after b/idea/testData/multiModuleQuickFix/expectClassWithVararg/jvm/My.kt.after new file mode 100644 index 00000000000..44a6bd7b5e4 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/expectClassWithVararg/jvm/My.kt.after @@ -0,0 +1,4 @@ +// "Create expected annotation class in common module testModule_Common" "true" +// DISABLE-ERRORS + +actual annotation class My actual constructor(actual vararg val arg: String) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java index ce0186d306d..22a4a0f0023 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java @@ -364,6 +364,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul runTest("idea/testData/multiModuleQuickFix/expectClassWithSupertype/"); } + @TestMetadata("expectClassWithVararg") + public void testExpectClassWithVararg() throws Exception { + runTest("idea/testData/multiModuleQuickFix/expectClassWithVararg/"); + } + @TestMetadata("expectCompanion") public void testExpectCompanion() throws Exception { runTest("idea/testData/multiModuleQuickFix/expectCompanion/");