Don't mangle synthesized 'box' function for inline classes
This commit is contained in:
committed by
Ilya Gorbunov
parent
ea2c33a532
commit
583c66a2a7
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen.state
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
|
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.SUCCESS_OR_FAILURE_FQ_NAME
|
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.fqNameSafe
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||||
import org.jetbrains.kotlin.resolve.isInlineClassType
|
import org.jetbrains.kotlin.resolve.isInlineClassType
|
||||||
@@ -17,6 +18,7 @@ import java.security.MessageDigest
|
|||||||
fun getInlineClassValueParametersManglingSuffix(descriptor: CallableMemberDescriptor): String? {
|
fun getInlineClassValueParametersManglingSuffix(descriptor: CallableMemberDescriptor): String? {
|
||||||
if (descriptor !is FunctionDescriptor) return null
|
if (descriptor !is FunctionDescriptor) return null
|
||||||
if (descriptor is ConstructorDescriptor) return null
|
if (descriptor is ConstructorDescriptor) return null
|
||||||
|
if (descriptor.isSynthesizedBoxMethod()) return null
|
||||||
|
|
||||||
val actualValueParameterTypes = listOfNotNull(descriptor.extensionReceiverParameter?.type) + descriptor.valueParameters.map { it.type }
|
val actualValueParameterTypes = listOfNotNull(descriptor.extensionReceiverParameter?.type) + descriptor.valueParameters.map { it.type }
|
||||||
|
|
||||||
@@ -39,6 +41,11 @@ private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Bool
|
|||||||
return getRepresentativeUpperBound(descriptor).requiresFunctionNameMangling()
|
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<KotlinType>) =
|
private fun collectSignatureForMangling(types: List<KotlinType>) =
|
||||||
types.joinToString { getSignatureElementForMangling(it) }
|
types.joinToString { getSignatureElementForMangling(it) }
|
||||||
|
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
|
inline class Z1(val x: Int)
|
||||||
|
inline class Z2(val x: Z1)
|
||||||
|
|
||||||
|
fun test(zs: MutableList<Z2>, z: Z2) {
|
||||||
|
zs.add(z)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1 public final static box\(I\)LZ2;
|
||||||
|
// 1 INVOKESTATIC Z2\$Erased.box \(I\)LZ2;
|
||||||
@@ -2133,6 +2133,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/skipCallToUnderlyingValueOfInlineClass.kt");
|
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")
|
@TestMetadata("uIntArrayIteratorWithoutBoxing.kt")
|
||||||
public void testUIntArrayIteratorWithoutBoxing() throws Exception {
|
public void testUIntArrayIteratorWithoutBoxing() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt");
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user