From fbe66c3496d082d2d487b2c39673f0cd4ac5b70a Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 26 Aug 2019 12:15:25 +0200 Subject: [PATCH] JVM IR: fix another naming inconsistency with old backend This fixes slice rewrite stacktraces from RecordNamesForKotlinTypeMapper which are printed out when running some JVM IR tests (even though they're ignored), e.g. localClassSimpleName.kt --- .../kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt | 6 ++++++ .../testData/checkLocalVariablesTable/itInReturnedLambda.kt | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt index 1c1fdfac96d..0e4b771d7d3 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt @@ -107,6 +107,12 @@ class InventNamesForLocalClasses(private val context: JvmBackendContext) : FileL localFunctionNames[(declaration as IrFunction).symbol] = name } } + declaration is IrFunction && declaration.parent !is IrClass -> { + // In the old backend, only names of non-local functions are stored in names of anonymous classes. All other names + // are replaced with indices. For example, a local class `L` in a top-level function `f` will have the name `...$f$L`, + // but inside a local function `g` (which is in `f`) it will have the name `...$f$1$L` (_not_ `...$f$g$L`). + inventName(null, data) + } enclosingName != null -> "$enclosingName$$simpleName" else -> simpleName } diff --git a/compiler/testData/checkLocalVariablesTable/itInReturnedLambda.kt b/compiler/testData/checkLocalVariablesTable/itInReturnedLambda.kt index c57dd18cbba..23478ff5561 100644 --- a/compiler/testData/checkLocalVariablesTable/itInReturnedLambda.kt +++ b/compiler/testData/checkLocalVariablesTable/itInReturnedLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun foo() { fun bar() : (Int) -> Unit { return {