diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt index 4026f3fb9e8..e0eba14a53c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt @@ -34,7 +34,7 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue -private const val COROUTINES_METADATA_SOURCE_FILES_JVM_NAME = "f" +private const val COROUTINES_METADATA_SOURCE_FILE_JVM_NAME = "f" private const val COROUTINES_METADATA_LINE_NUMBERS_JVM_NAME = "l" private const val COROUTINES_METADATA_LOCAL_NAMES_JVM_NAME = "n" private const val COROUTINES_METADATA_SPILLED_JVM_NAME = "s" @@ -194,10 +194,7 @@ class CoroutineTransformerMethodVisitor( label.safeAs()?.findNextOrNull { it is LineNumberNode }.safeAs()?.line ?: -1 } val metadata = classBuilderForCoroutineState.newAnnotation(DEBUG_METADATA_ANNOTATION_ASM_TYPE.descriptor, true) - // TODO: support inlined functions (similar to SMAP) - metadata.visitArray(COROUTINES_METADATA_SOURCE_FILES_JVM_NAME).also { v -> - lines.forEach { v.visit(null, sourceFile) } - }.visitEnd() + metadata.visit(COROUTINES_METADATA_SOURCE_FILE_JVM_NAME, sourceFile) metadata.visit(COROUTINES_METADATA_LINE_NUMBERS_JVM_NAME, lines.toIntArray()) val debugIndexToLabel = spilledToLocalMapping.withIndex().flatMap { (labelIndex, list) -> diff --git a/libraries/stdlib/coroutines/jvm/src/kotlin/coroutines/jvm/internal/DebugMetadata.kt b/libraries/stdlib/coroutines/jvm/src/kotlin/coroutines/jvm/internal/DebugMetadata.kt index d7510c0bb84..67e53b7212e 100644 --- a/libraries/stdlib/coroutines/jvm/src/kotlin/coroutines/jvm/internal/DebugMetadata.kt +++ b/libraries/stdlib/coroutines/jvm/src/kotlin/coroutines/jvm/internal/DebugMetadata.kt @@ -11,7 +11,7 @@ import kotlin.coroutines.Continuation @SinceKotlin("1.3") internal annotation class DebugMetadata( @get:JvmName("f") - val sourceFiles: Array, + val sourceFile: String, @get:JvmName("l") val lineNumbers: IntArray, @get:JvmName("n") @@ -39,9 +39,8 @@ internal annotation class DebugMetadata( internal fun BaseContinuationImpl.getStackTraceElementImpl(): StackTraceElement? { val debugMetadata = getDebugMetadataAnnotation() ?: return null val label = getLabel() - val fileName = if (label < 0) "" else debugMetadata.sourceFiles[label] val lineNumber = if (label < 0) -1 else debugMetadata.lineNumbers[label] - return StackTraceElement(debugMetadata.className, debugMetadata.methodName, fileName, lineNumber) + return StackTraceElement(debugMetadata.className, debugMetadata.methodName, debugMetadata.sourceFile, lineNumber) } private fun BaseContinuationImpl.getDebugMetadataAnnotation(): DebugMetadata? = diff --git a/libraries/stdlib/coroutines/jvm/test/DebugMetadataTest.kt b/libraries/stdlib/coroutines/jvm/test/DebugMetadataTest.kt index c89f5e37389..364ea717eb9 100644 --- a/libraries/stdlib/coroutines/jvm/test/DebugMetadataTest.kt +++ b/libraries/stdlib/coroutines/jvm/test/DebugMetadataTest.kt @@ -19,8 +19,8 @@ import kotlin.test.assertEquals */ @DebugMetadata( - sourceFiles = ["test.kt", "test1.kt", "test.kt"], - lineNumbers = [10, 2, 11], + sourceFile = "test.kt", + lineNumbers = [10, 122, 11], indexToLabel = [0, 0, 1, 1, 2], localNames = ["a", "b", "b", "c", "c"], spilled = ["L$1", "L$2", "L$1", "L$2", "L$1"], @@ -49,7 +49,7 @@ class DebugMetadataTest { assertEquals(listOf("L$1", "a", "L$2", "b"), myContinuation.getSpilledVariableFieldMapping()!!.toList()) myContinuation.label = 2 assertEquals( - StackTraceElement("SomeClass", "testMethod", "test1.kt", 2), + StackTraceElement("SomeClass", "testMethod", "test.kt", 122), myContinuation.getStackTraceElement() ) assertEquals(listOf("L$1", "b", "L$2", "c"), myContinuation.getSpilledVariableFieldMapping()!!.toList())