JVM IR: Fix inline class mangling for calls to internal functions
...in a different module, e.g., using -Xfriend-paths.
This commit is contained in:
committed by
Ilmir Usmanov
parent
6747084fe2
commit
482e217b5e
+5
@@ -245,6 +245,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalWithInlineClass.kt")
|
||||||
|
public void testInternalWithInlineClass() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("internalWithOtherModuleName.kt")
|
@TestMetadata("internalWithOtherModuleName.kt")
|
||||||
public void testInternalWithOtherModuleName() throws Exception {
|
public void testInternalWithOtherModuleName() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
||||||
|
|||||||
+4
-1
@@ -134,7 +134,10 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
|||||||
origin != JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS &&
|
origin != JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS &&
|
||||||
!isPublishedApi()
|
!isPublishedApi()
|
||||||
) {
|
) {
|
||||||
return this
|
return originalFunction.takeIf { it != this }
|
||||||
|
?.safeAs<IrSimpleFunction>()
|
||||||
|
?.getInternalFunctionForManglingIfNeeded()
|
||||||
|
?: this
|
||||||
}
|
}
|
||||||
originalForDefaultAdapter?.getInternalFunctionForManglingIfNeeded()?.let { return it }
|
originalForDefaultAdapter?.getInternalFunctionForManglingIfNeeded()?.let { return it }
|
||||||
return null
|
return null
|
||||||
|
|||||||
+3
-2
@@ -383,12 +383,13 @@ fun IrSimpleType.isRawType(): Boolean =
|
|||||||
hasAnnotation(JvmGeneratorExtensions.RAW_TYPE_ANNOTATION_FQ_NAME)
|
hasAnnotation(JvmGeneratorExtensions.RAW_TYPE_ANNOTATION_FQ_NAME)
|
||||||
|
|
||||||
internal fun classFileContainsMethod(classId: ClassId, function: IrFunction, context: JvmBackendContext): Boolean? {
|
internal fun classFileContainsMethod(classId: ClassId, function: IrFunction, context: JvmBackendContext): Boolean? {
|
||||||
val originalDescriptor = context.methodSignatureMapper.mapSignatureWithGeneric(function).asmMethod.descriptor
|
val originalSignature = context.methodSignatureMapper.mapSignatureWithGeneric(function).asmMethod
|
||||||
|
val originalDescriptor = originalSignature.descriptor
|
||||||
val descriptor = if (function.isSuspend)
|
val descriptor = if (function.isSuspend)
|
||||||
listOf(*Type.getArgumentTypes(originalDescriptor), Type.getObjectType("kotlin/coroutines/Continuation"))
|
listOf(*Type.getArgumentTypes(originalDescriptor), Type.getObjectType("kotlin/coroutines/Continuation"))
|
||||||
.joinToString(prefix = "(", postfix = ")", separator = "") + AsmTypes.OBJECT_TYPE
|
.joinToString(prefix = "(", postfix = ")", separator = "") + AsmTypes.OBJECT_TYPE
|
||||||
else originalDescriptor
|
else originalDescriptor
|
||||||
return classFileContainsMethod(classId, context.state, Method(function.name.asString(), descriptor))
|
return classFileContainsMethod(classId, context.state, Method(originalSignature.name, descriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
val IrMemberWithContainerSource.parentClassId: ClassId?
|
val IrMemberWithContainerSource.parentClassId: ClassId?
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// FILE: A.kt
|
||||||
|
|
||||||
|
package a
|
||||||
|
|
||||||
|
inline class Message(val value: String)
|
||||||
|
|
||||||
|
class Box {
|
||||||
|
internal fun result(msg: Message): String = msg.value
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return a.Box().result(a.Message("OK"))
|
||||||
|
}
|
||||||
Generated
+5
@@ -244,6 +244,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalWithInlineClass.kt")
|
||||||
|
public void testInternalWithInlineClass() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("internalWithOtherModuleName.kt")
|
@TestMetadata("internalWithOtherModuleName.kt")
|
||||||
public void testInternalWithOtherModuleName() throws Exception {
|
public void testInternalWithOtherModuleName() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
||||||
|
|||||||
Generated
+5
@@ -245,6 +245,11 @@ public class IrCompileKotlinAgainstKotlinTestGenerated extends AbstractIrCompile
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalWithInlineClass.kt")
|
||||||
|
public void testInternalWithInlineClass() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("internalWithOtherModuleName.kt")
|
@TestMetadata("internalWithOtherModuleName.kt")
|
||||||
public void testInternalWithOtherModuleName() throws Exception {
|
public void testInternalWithOtherModuleName() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
||||||
|
|||||||
+5
@@ -245,6 +245,11 @@ public class JvmIrAgainstOldBoxTestGenerated extends AbstractJvmIrAgainstOldBoxT
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalWithInlineClass.kt")
|
||||||
|
public void testInternalWithInlineClass() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("internalWithOtherModuleName.kt")
|
@TestMetadata("internalWithOtherModuleName.kt")
|
||||||
public void testInternalWithOtherModuleName() throws Exception {
|
public void testInternalWithOtherModuleName() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
||||||
|
|||||||
+5
@@ -245,6 +245,11 @@ public class JvmOldAgainstIrBoxTestGenerated extends AbstractJvmOldAgainstIrBoxT
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithDefaultArgs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalWithInlineClass.kt")
|
||||||
|
public void testInternalWithInlineClass() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithInlineClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("internalWithOtherModuleName.kt")
|
@TestMetadata("internalWithOtherModuleName.kt")
|
||||||
public void testInternalWithOtherModuleName() throws Exception {
|
public void testInternalWithOtherModuleName() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/internalWithOtherModuleName.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user