diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt index 5170d9a3921..5db029669de 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt @@ -332,6 +332,9 @@ internal class Context(config: KonanConfig) : KonanBackendContext(config) { config.librariesWithDependencies(moduleDescriptor) } + var functionReferenceCount = 0 + var coroutineCount = 0 + fun needGlobalInit(field: IrField): Boolean { if (field.descriptor.containingDeclaration !is PackageFragmentDescriptor) return false // TODO: add some smartness here. Maybe if package of the field is in never accessed diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt index 714e9029ac8..cebbac1c23e 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt @@ -47,8 +47,6 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass private object DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL : IrDeclarationOriginImpl("FUNCTION_REFERENCE_IMPL") - private var functionReferenceCount = 0 - override fun lower(irFile: IrFile) { irFile.transform(object: IrElementTransformerVoidWithContext() { @@ -184,7 +182,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass functionReferenceClassDescriptor = object : ClassDescriptorImpl( /* containingDeclaration = */ containingDeclaration, - /* name = */ "${functionDescriptor.name}\$${functionReferenceCount++}".synthesizedName, + /* name = */ "${functionDescriptor.name}\$FUNCTION_REFERENCE\$${context.functionReferenceCount++}".synthesizedName, /* modality = */ Modality.FINAL, /* kind = */ ClassKind.CLASS, /* superTypes = */ superTypes.map { it.toKotlinType() }, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt index 280dc2a6686..7e8d0ec484b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt @@ -252,8 +252,6 @@ internal class SuspendFunctionsLowering(val context: Context): FileLoweringPass val coroutineConstructor: IrConstructor, val invokeSuspendFunction: IrFunction) - private var coroutineId = 0 - private val COROUTINES_FQ_NAME = FqName.fromSegments(listOf("kotlin", "coroutines", "experimental")) private val KOTLIN_FQ_NAME = FqName("kotlin") @@ -310,7 +308,7 @@ internal class SuspendFunctionsLowering(val context: Context): FileLoweringPass } coroutineClassDescriptor = ClassDescriptorImpl( /* containingDeclaration = */ irFunction.descriptor.containingDeclaration, - /* name = */ "${irFunction.descriptor.name}\$${coroutineId++}".synthesizedName, + /* name = */ "${irFunction.descriptor.name}\$COROUTINE\$${context.coroutineCount++}".synthesizedName, /* modality = */ Modality.FINAL, /* kind = */ ClassKind.CLASS, /* superTypes = */ superTypes.map { it.toKotlinType() },