diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt index d5cb052a383..fd1620a1e4c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt @@ -84,15 +84,20 @@ class SourceMapper(val sourceInfo: SourceInfo?) { val resultMappings: List get() = fileMappings.values.toList() + companion object { + const val FAKE_FILE_NAME = "fake.kt" + const val FAKE_PATH = "kotlin/jvm/internal/FakeKt" + } + init { sourceInfo?.let { sourceInfo -> - // If 'sourceFileName' is null, this class doesn't have debug information - // (e.g., multi-file class facade with multiple parts). - sourceInfo.sourceFileName?.let { sourceFileName -> - // Explicitly map the file to itself -- we'll probably need a lot of lines from it, so this will produce fewer ranges. - getOrRegisterNewSource(sourceFileName, sourceInfo.pathOrCleanFQN) - .mapNewInterval(1, 1, sourceInfo.linesInFile) - } + // If 'sourceFileName' is null we are dealing with a synthesized class + // (e.g., multi-file class facade with multiple parts). Such classes + // only have synthetic debug information and we use a fake file name. + val sourceFileName = sourceInfo.sourceFileName ?: FAKE_FILE_NAME + // Explicitly map the file to itself -- we'll probably need a lot of lines from it, so this will produce fewer ranges. + getOrRegisterNewSource(sourceFileName, sourceInfo.pathOrCleanFQN) + .mapNewInterval(1, 1, sourceInfo.linesInFile) } } @@ -110,7 +115,7 @@ class SourceMapper(val sourceInfo: SourceInfo?) { } fun mapSyntheticLineNumber(id: Int): Int { - return mapLineNumber(SourcePosition(id, "fake.kt", "kotlin/jvm/internal/FakeKt"), null) + return mapLineNumber(SourcePosition(id, FAKE_FILE_NAME, FAKE_PATH), null) } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index c9ed1bfcc97..ca76c49e925 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -213,6 +213,10 @@ class ExpressionCodegen( fun generate() { mv.visitCode() val startLabel = markNewLabel() + if (irFunction.origin == JvmLoweredDeclarationOrigin.MULTIFILE_BRIDGE) { + // Multifile bridges need to have line number 1 to be filtered out by the intellij debugging filters. + mv.visitLineNumber(1, startLabel) + } val info = BlockInfo() val body = irFunction.body!! generateNonNullAssertions() diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt index 15f7676b55b..5df20e09c14 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt @@ -90,7 +90,6 @@ fun JvmBackendContext.getSourceMapper(declaration: IrClass): SourceMapper { val fileEntry = sourceManager.getFileEntry(declaration.fileParent) // NOTE: apparently inliner requires the source range to cover the // whole file the class is declared in rather than the class only. - // TODO: revise val endLineNumber = when (fileEntry) { is MultifileFacadeFileEntry -> 0 else -> fileEntry?.getSourceRangeInfo(0, fileEntry.maxOffset)?.endLineNumber ?: 0 diff --git a/idea/jvm-debugger/jvm-debugger-test/testData/stepping/filters/stepIntoMultiFileFacade.out b/idea/jvm-debugger/jvm-debugger-test/testData/stepping/filters/stepIntoMultiFileFacade.out index aaefedd5698..24744a9d50e 100644 --- a/idea/jvm-debugger/jvm-debugger-test/testData/stepping/filters/stepIntoMultiFileFacade.out +++ b/idea/jvm-debugger/jvm-debugger-test/testData/stepping/filters/stepIntoMultiFileFacade.out @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR LineBreakpoint created at stepIntoMultiFileFacade.kt:6 Run Java Connected to the target VM