DescriptorRenderedImpl: fix order of val & vararg modifier for actual class
#KT-31921 Fixed
This commit is contained in:
@@ -821,14 +821,13 @@ internal class DescriptorRendererImpl(
|
|||||||
renderModifier(builder, valueParameter.isCrossinline, "crossinline")
|
renderModifier(builder, valueParameter.isCrossinline, "crossinline")
|
||||||
renderModifier(builder, valueParameter.isNoinline, "noinline")
|
renderModifier(builder, valueParameter.isNoinline, "noinline")
|
||||||
|
|
||||||
if (renderPrimaryConstructorParametersAsProperties &&
|
val isPrimaryConstructor = renderPrimaryConstructorParametersAsProperties &&
|
||||||
(valueParameter.containingDeclaration as? ClassConstructorDescriptor)?.isPrimary == true
|
(valueParameter.containingDeclaration as? ClassConstructorDescriptor)?.isPrimary == true
|
||||||
) {
|
if (isPrimaryConstructor) {
|
||||||
renderModifier(builder, actualPropertiesInPrimaryConstructor, "actual")
|
renderModifier(builder, actualPropertiesInPrimaryConstructor, "actual")
|
||||||
renderModifier(builder, true, "val")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderVariable(valueParameter, includeName, builder, topLevel)
|
renderVariable(valueParameter, includeName, builder, topLevel, isPrimaryConstructor)
|
||||||
|
|
||||||
val withDefaultValue =
|
val withDefaultValue =
|
||||||
defaultParameterValueRenderer != null &&
|
defaultParameterValueRenderer != null &&
|
||||||
@@ -838,21 +837,27 @@ internal class DescriptorRendererImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderValVarPrefix(variable: VariableDescriptor, builder: StringBuilder) {
|
private fun renderValVarPrefix(variable: VariableDescriptor, builder: StringBuilder, isInPrimaryConstructor: Boolean = false) {
|
||||||
if (variable !is ValueParameterDescriptor) {
|
if (isInPrimaryConstructor || variable !is ValueParameterDescriptor) {
|
||||||
builder.append(renderKeyword(if (variable.isVar) "var" else "val")).append(" ")
|
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 realType = variable.type
|
||||||
|
|
||||||
val varargElementType = (variable as? ValueParameterDescriptor)?.varargElementType
|
val varargElementType = (variable as? ValueParameterDescriptor)?.varargElementType
|
||||||
val typeToRender = varargElementType ?: realType
|
val typeToRender = varargElementType ?: realType
|
||||||
|
|
||||||
renderModifier(builder, varargElementType != null, "vararg")
|
renderModifier(builder, varargElementType != null, "vararg")
|
||||||
if (topLevel && !startFromName) {
|
|
||||||
renderValVarPrefix(variable, builder)
|
if (isInPrimaryConstructor || topLevel && !startFromName) {
|
||||||
|
renderValVarPrefix(variable, builder, isInPrimaryConstructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeName) {
|
if (includeName) {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// My: to be implemented
|
||||||
|
// DISABLE-ERRORS
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// My: to be implemented
|
||||||
|
// DISABLE-ERRORS
|
||||||
|
expect annotation class My(vararg val arg: String)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// "Create expected annotation class in common module testModule_Common" "true"
|
||||||
|
// DISABLE-ERRORS
|
||||||
|
|
||||||
|
actual annotation class <caret>My actual constructor(actual vararg val arg: String)
|
||||||
@@ -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)
|
||||||
+5
@@ -364,6 +364,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
|||||||
runTest("idea/testData/multiModuleQuickFix/expectClassWithSupertype/");
|
runTest("idea/testData/multiModuleQuickFix/expectClassWithSupertype/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("expectClassWithVararg")
|
||||||
|
public void testExpectClassWithVararg() throws Exception {
|
||||||
|
runTest("idea/testData/multiModuleQuickFix/expectClassWithVararg/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("expectCompanion")
|
@TestMetadata("expectCompanion")
|
||||||
public void testExpectCompanion() throws Exception {
|
public void testExpectCompanion() throws Exception {
|
||||||
runTest("idea/testData/multiModuleQuickFix/expectCompanion/");
|
runTest("idea/testData/multiModuleQuickFix/expectCompanion/");
|
||||||
|
|||||||
Reference in New Issue
Block a user