JVM_IR: refine the condition for mangling names of multifile members

Private $$forInline versions of public suspend functions should not
be mangled. (Note that there are no $$forInline versions of private
suspend functions, as those are effectively inline-only.)
This commit is contained in:
pyos
2020-03-06 10:35:35 +01:00
committed by Ilmir Usmanov
parent 8fbfa8b819
commit 8487211ae1
6 changed files with 56 additions and 2 deletions
@@ -112,8 +112,8 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
val newName = JvmCodegenUtil.sanitizeNameIfNeeded(name, context.state.languageVersionSettings)
if (function.isTopLevel) {
if (Visibilities.isPrivate(function.visibility) && newName != "<clinit>" &&
(function.parent as? IrClass)?.attributeOwnerId in context.multifileFacadeForPart
if (Visibilities.isPrivate(if (function.isSuspend) function.suspendFunctionOriginal().visibility else function.visibility) &&
newName != "<clinit>" && (function.parent as? IrClass)?.attributeOwnerId in context.multifileFacadeForPart
) {
return "$newName$${function.parentAsClass.name.asString()}"
}
@@ -0,0 +1,34 @@
// FILE: test.kt
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// TARGET_BACKEND: JVM
// !INHERIT_MULTIFILE_PARTS
// The lambda in box() attempts to store the result in a null Ref for some reason.
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_MULTI_MODULE: JVM
@file:JvmMultifileClass
@file:JvmName("XKt")
suspend fun suspendHere() {}
suspend inline fun test(c: suspend () -> String): String {
suspendHere()
val result = c()
suspendHere()
return result
}
// FILE: box.kt
import kotlin.coroutines.*
import helpers.*
fun box() : String {
var res = "fail"
suspend {
res = test { "OK" }
}.startCoroutine(EmptyContinuation)
return res
}
@@ -3718,6 +3718,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendContinuation.kt", "kotlin.coroutines");
}
@TestMetadata("inlineSuspendInMultifileClass.kt")
public void testInlineSuspendInMultifileClass() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendInMultifileClass.kt");
}
@TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt")
public void testInlineSuspendOfCrossinlineOrdinary_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt", "kotlin.coroutines.experimental");
@@ -3718,6 +3718,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendContinuation.kt", "kotlin.coroutines");
}
@TestMetadata("inlineSuspendInMultifileClass.kt")
public void testInlineSuspendInMultifileClass() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendInMultifileClass.kt");
}
@TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt")
public void testInlineSuspendOfCrossinlineOrdinary_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt", "kotlin.coroutines.experimental");
@@ -3683,6 +3683,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendContinuation.kt", "kotlin.coroutines");
}
@TestMetadata("inlineSuspendInMultifileClass.kt")
public void testInlineSuspendInMultifileClass() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendInMultifileClass.kt");
}
@TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt")
public void testInlineSuspendOfCrossinlineOrdinary_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt", "kotlin.coroutines");
@@ -3683,6 +3683,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendContinuation.kt", "kotlin.coroutines");
}
@TestMetadata("inlineSuspendInMultifileClass.kt")
public void testInlineSuspendInMultifileClass() throws Exception {
runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendInMultifileClass.kt");
}
@TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt")
public void testInlineSuspendOfCrossinlineOrdinary_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt", "kotlin.coroutines");