From 137ef26723739b41c4c7f5b58002fc46553e14f2 Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Tue, 7 Jan 2020 14:20:35 -0800 Subject: [PATCH] [JVM IR] Fix issue with destructuring declaration in parameter for suspend lambda. The Name for the special destructuring declaration parameter was incorrectly turned into a regular/non-special Name when the parameter was moved to a field. --- .../kotlin/ir/builders/declarations/declarationBuilders.kt | 7 +++++-- .../kotlin/backend/jvm/lower/AddContinuationLowering.kt | 2 +- .../featureIntersection/destructuringInLambdas.kt | 1 - .../featureIntersection/suspendDestructuringInLambdas.kt | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt index 9628c2ca87c..511b8f5348d 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt @@ -63,13 +63,16 @@ inline fun IrDeclarationContainer.addField(builder: IrFieldBuilder.() -> Unit) = declarations.add(field) } -fun IrClass.addField(fieldName: String, fieldType: IrType, fieldVisibility: Visibility = Visibilities.PRIVATE): IrField = +fun IrClass.addField(fieldName: Name, fieldType: IrType, fieldVisibility: Visibility = Visibilities.PRIVATE): IrField = addField { - name = Name.identifier(fieldName) + name = fieldName type = fieldType visibility = fieldVisibility } +fun IrClass.addField(fieldName: String, fieldType: IrType, fieldVisibility: Visibility = Visibilities.PRIVATE): IrField = + addField(Name.identifier(fieldName), fieldType, fieldVisibility) + fun IrPropertyBuilder.buildProperty(): IrProperty { val wrappedDescriptor = WrappedPropertyDescriptor() return IrPropertyImpl( diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index db90f0473e4..b997d36cfd8 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -114,7 +114,7 @@ private class AddContinuationLowering(private val context: JvmBackendContext) : addField("p\$", it.type) } - val parametersFields = info.function.valueParameters.map { addField(it.name.asString(), it.type) } + val parametersFields = info.function.valueParameters.map { addField(it.name, it.type) } val parametersWithoutArguments = parametersFields.withIndex() .mapNotNull { (i, field) -> if (info.reference.getValueArgument(i) == null) field else null } val parametersWithArguments = parametersFields - parametersWithoutArguments diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt index a932e06bf33..05066cfa29c 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendDestructuringInLambdas.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendDestructuringInLambdas.kt index 893bd844e20..e6a3ac65255 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendDestructuringInLambdas.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendDestructuringInLambdas.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST