diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index c2181ae7c1f..e75a49fedf1 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -1810,7 +1810,7 @@ private fun ObjCExportCodeGenerator.findImplementation(irClass: IrClass, method: val override = irClass.simpleFunctions().singleOrNull { method in it.getLowered().allOverriddenFunctions } ?: error("no implementation for ${method.render()}\nin ${irClass.fqNameWhenAvailable}") - return OverriddenFunctionInfo(override, method).getImplementation(context) + return OverriddenFunctionInfo(override.getLowered(), method).getImplementation(context) } private inline fun ObjCExportCodeGenerator.generateObjCToKotlinSyntheticGetter( diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazy.h b/kotlin-native/backend.native/tests/objcexport/expectedLazy.h index 68cd285a787..cd9338e16db 100644 --- a/kotlin-native/backend.native/tests/objcexport/expectedLazy.h +++ b/kotlin-native/backend.native/tests/objcexport/expectedLazy.h @@ -1098,6 +1098,22 @@ __attribute__((swift_name("Kt54119Kt"))) + (BOOL)callContainsEntryMap:(NSDictionary *)map __attribute__((swift_name("callContainsEntry(map:)"))); @end +@interface KtKotlinSequenceScope (Kt55736Kt) + +/** + * @note This method converts instances of CancellationException to errors. + * Other uncaught Kotlin exceptions are fatal. +*/ +- (void)fillWithCompletionHandler:(void (^)(NSError * _Nullable))completionHandler __attribute__((swift_name("fill(completionHandler:)"))); +@end + +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("Kt55736Kt"))) +@interface KtKt55736Kt : KtBase ++ (id)getFillFunction __attribute__((swift_name("getFillFunction()"))); ++ (NSArray *)callbackBlock:(id)block __attribute__((swift_name("callback(block:)"))); +@end + __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("LibraryKt"))) @interface KtLibraryKt : KtBase diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h b/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h index ef10b463cab..0c13e8b9b9f 100644 --- a/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h +++ b/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h @@ -1033,6 +1033,22 @@ __attribute__((swift_name("Kt54119Kt"))) + (BOOL)callContainsEntryMap:(NSDictionary *)map __attribute__((swift_name("callContainsEntry(map:)"))); @end +@interface KtKotlinSequenceScope (Kt55736Kt) + +/** + * @note This method converts instances of CancellationException to errors. + * Other uncaught Kotlin exceptions are fatal. +*/ +- (void)fillWithCompletionHandler:(void (^)(KtKotlinUnit * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("fill(completionHandler:)"))); +@end + +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("Kt55736Kt"))) +@interface KtKt55736Kt : KtBase ++ (id)getFillFunction __attribute__((swift_name("getFillFunction()"))); ++ (NSArray *)callbackBlock:(id)block __attribute__((swift_name("callback(block:)"))); +@end + __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("LibraryKt"))) @interface KtLibraryKt : KtBase diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h b/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h index 218a606fd09..d5156d32588 100644 --- a/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h +++ b/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h @@ -1033,6 +1033,22 @@ __attribute__((swift_name("Kt54119Kt"))) + (BOOL)callContainsEntryMap:(NSDictionary *)map __attribute__((swift_name("callContainsEntry(map:)"))); @end +@interface KtKotlinSequenceScope (Kt55736Kt) + +/** + * @note This method converts instances of CancellationException to errors. + * Other uncaught Kotlin exceptions are fatal. +*/ +- (void)fillWithCompletionHandler:(void (^)(NSError * _Nullable))completionHandler __attribute__((swift_name("fill(completionHandler:)"))); +@end + +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("Kt55736Kt"))) +@interface KtKt55736Kt : KtBase ++ (id)getFillFunction __attribute__((swift_name("getFillFunction()"))); ++ (NSArray *)callbackBlock:(id)block __attribute__((swift_name("callback(block:)"))); +@end + __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("LibraryKt"))) @interface KtLibraryKt : KtBase diff --git a/kotlin-native/backend.native/tests/objcexport/kt55736.kt b/kotlin-native/backend.native/tests/objcexport/kt55736.kt new file mode 100644 index 00000000000..8055c13aa3e --- /dev/null +++ b/kotlin-native/backend.native/tests/objcexport/kt55736.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.sequences.* + +suspend fun SequenceScope.fill() { + yield(1) + yield(2) +} + +fun getFillFunction() = SequenceScope::fill + +fun callback(block: suspend SequenceScope.() -> Unit) : List { + return sequence { + block() + }.toList() +} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/objcexport/kt55736.swift b/kotlin-native/backend.native/tests/objcexport/kt55736.swift new file mode 100644 index 00000000000..b0c4107d668 --- /dev/null +++ b/kotlin-native/backend.native/tests/objcexport/kt55736.swift @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import Foundation +import Kt + +private func testFill() throws { + let result = Kt55736Kt.callback(block: Kt55736Kt.getFillFunction()) + try assertEquals(actual: result.count, expected: 2) + try assertEquals(actual: result[0], expected: 1) + try assertEquals(actual: result[1], expected: 2) +} + +class Kt55736Tests : SimpleTestProvider { + override init() { + super.init() + + test("testFill", testFill) + } +}