Use class name instead internal name in coroutines debug metadata

I.e. instead of slashes use dots in fqnames.

 #KT-28237 Fixed
This commit is contained in:
Ilmir Usmanov
2018-11-20 15:21:02 +03:00
parent 5483ce0933
commit bdd1eef39a
5 changed files with 57 additions and 1 deletions
@@ -284,7 +284,7 @@ class CoroutineTransformerMethodVisitor(
variablesMapping.forEach { v.visit(null, it.variableName) }
}.visitEnd()
metadata.visit(COROUTINES_METADATA_METHOD_NAME_JVM_NAME, methodNode.name)
metadata.visit(COROUTINES_METADATA_CLASS_NAME_JVM_NAME, containingClassInternalName)
metadata.visit(COROUTINES_METADATA_CLASS_NAME_JVM_NAME, Type.getObjectType(containingClassInternalName).className)
@Suppress("ConstantConditionIf")
if (COROUTINES_DEBUG_METADATA_VERSION != 1) {
metadata.visit(COROUTINES_METADATA_VERSION_JVM_NAME, COROUTINES_DEBUG_METADATA_VERSION)
@@ -0,0 +1,41 @@
// !LANGUAGE: +ReleaseCoroutines
// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FULL_JDK
// WITH_COROUTINES
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER")
package some.long.name
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
import kotlin.coroutines.jvm.internal.*
suspend fun dummy() {}
class Test {
suspend fun getStackTraceElement(): StackTraceElement {
dummy() // to force state-machine generation
return suspendCoroutineUninterceptedOrReturn<StackTraceElement> {
(it as BaseContinuationImpl).getStackTraceElement()
}
}
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var res = "OK"
builder {
if (Test().getStackTraceElement().className != "some.long.name.Test") {
res = Test().getStackTraceElement().className
}
}
return res
}
@@ -6592,6 +6592,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
}
@TestMetadata("fqName.kt")
public void testFqName() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/debug/fqName.kt");
}
@TestMetadata("runtimeDebugMetadata.kt")
public void testRuntimeDebugMetadata() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt");
@@ -6592,6 +6592,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
}
@TestMetadata("fqName.kt")
public void testFqName() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/debug/fqName.kt");
}
@TestMetadata("runtimeDebugMetadata.kt")
public void testRuntimeDebugMetadata() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt");
@@ -6592,6 +6592,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
}
@TestMetadata("fqName.kt")
public void testFqName() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/debug/fqName.kt");
}
@TestMetadata("runtimeDebugMetadata.kt")
public void testRuntimeDebugMetadata() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt");