diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt index 775d177b38f..bb49a3d3889 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen.state import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound import org.jetbrains.kotlin.resolve.DescriptorUtils.SUCCESS_OR_FAILURE_FQ_NAME +import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver.BOX_METHOD_NAME import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.resolve.isInlineClassType @@ -17,6 +18,7 @@ import java.security.MessageDigest fun getInlineClassValueParametersManglingSuffix(descriptor: CallableMemberDescriptor): String? { if (descriptor !is FunctionDescriptor) return null if (descriptor is ConstructorDescriptor) return null + if (descriptor.isSynthesizedBoxMethod()) return null val actualValueParameterTypes = listOfNotNull(descriptor.extensionReceiverParameter?.type) + descriptor.valueParameters.map { it.type } @@ -39,6 +41,11 @@ private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Bool return getRepresentativeUpperBound(descriptor).requiresFunctionNameMangling() } +private fun FunctionDescriptor.isSynthesizedBoxMethod() = + kind == CallableMemberDescriptor.Kind.SYNTHESIZED && + containingDeclaration.let { it is ClassDescriptor && it.isInline } && + name == BOX_METHOD_NAME + private fun collectSignatureForMangling(types: List) = types.joinToString { getSignatureElementForMangling(it) } diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/synthesizedBoxMethodIsNotMangled.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/synthesizedBoxMethodIsNotMangled.kt new file mode 100644 index 00000000000..502ad15b22e --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/synthesizedBoxMethodIsNotMangled.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses + +inline class Z1(val x: Int) +inline class Z2(val x: Z1) + +fun test(zs: MutableList, z: Z2) { + zs.add(z) +} + +// 1 public final static box\(I\)LZ2; +// 1 INVOKESTATIC Z2\$Erased.box \(I\)LZ2; \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 57f1cb7095e..24babb43116 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2133,6 +2133,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/skipCallToUnderlyingValueOfInlineClass.kt"); } + @TestMetadata("synthesizedBoxMethodIsNotMangled.kt") + public void testSynthesizedBoxMethodIsNotMangled() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/synthesizedBoxMethodIsNotMangled.kt"); + } + @TestMetadata("uIntArrayIteratorWithoutBoxing.kt") public void testUIntArrayIteratorWithoutBoxing() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt");