@@ -8,13 +8,14 @@ package org.jetbrains.kotlin.backend.common.lower
8
8
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
9
9
import org.jetbrains.kotlin.backend.common.CommonBackendContext
10
10
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedString
11
- import org.jetbrains.kotlin.backend.common.ir.*
12
11
import org.jetbrains.kotlin.backend.common.lower.inline.isInlineParameter
13
12
import org.jetbrains.kotlin.backend.common.runOnFilePostfix
14
13
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
15
14
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
16
15
import org.jetbrains.kotlin.descriptors.Modality
17
- import org.jetbrains.kotlin.ir.*
16
+ import org.jetbrains.kotlin.ir.IrElement
17
+ import org.jetbrains.kotlin.ir.IrStatement
18
+ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
18
19
import org.jetbrains.kotlin.ir.builders.declarations.buildConstructor
19
20
import org.jetbrains.kotlin.ir.builders.declarations.buildFun
20
21
import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter
@@ -25,7 +26,9 @@ import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
25
26
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
26
27
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
27
28
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
28
- import org.jetbrains.kotlin.ir.types.*
29
+ import org.jetbrains.kotlin.ir.transformStatement
30
+ import org.jetbrains.kotlin.ir.types.IrType
31
+ import org.jetbrains.kotlin.ir.types.defaultType
29
32
import org.jetbrains.kotlin.ir.util.*
30
33
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
31
34
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -71,6 +74,7 @@ class LocalDeclarationsLowering(
71
74
val localNameSanitizer : (String ) -> String = { it },
72
75
val visibilityPolicy : VisibilityPolicy = VisibilityPolicy .DEFAULT ,
73
76
val suggestUniqueNames : Boolean = true , // When `true` appends a `$#index` suffix to lifted declaration names
77
+ val compatibilityModeForInlinedLocalDelegatedPropertyAccessors : Boolean = false , // Keep old names because of KT-49030
74
78
val forceFieldsForInlineCaptures : Boolean = false , // See `LocalClassContext`
75
79
private val postLocalDeclarationLoweringCallback : ((IntermediateDatastructures ) -> Unit )? = null
76
80
) :
@@ -589,8 +593,16 @@ class LocalDeclarationsLowering(
589
593
val declarationName = localNameSanitizer(declaration.name.asString())
590
594
localFunctions[declaration]?.let {
591
595
val baseName = if (declaration.name.isSpecial) " lambda" else declarationName
592
- if (it.index >= 0 )
593
- return if (suggestUniqueNames) " $baseName \$ ${it.index} " else baseName
596
+ if (it.index >= 0 ) {
597
+ if (! suggestUniqueNames) return baseName
598
+
599
+ val separator = if (
600
+ compatibilityModeForInlinedLocalDelegatedPropertyAccessors &&
601
+ declaration.origin == IrDeclarationOrigin .DELEGATED_PROPERTY_ACCESSOR &&
602
+ container is IrFunction && container.isInline
603
+ ) " -" else " $"
604
+ return " $baseName$separator${it.index} "
605
+ }
594
606
}
595
607
596
608
return declarationName
0 commit comments