[K/N] Fix crash on exporting cached suspend function
^KT-55736
This commit is contained in:
committed by
Space Team
parent
25fb641da7
commit
5674722742
+1
-1
@@ -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(
|
||||
|
||||
@@ -1098,6 +1098,22 @@ __attribute__((swift_name("Kt54119Kt")))
|
||||
+ (BOOL)callContainsEntryMap:(NSDictionary<id, id> *)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<KtKotlinKSuspendFunction1>)getFillFunction __attribute__((swift_name("getFillFunction()")));
|
||||
+ (NSArray<KtInt *> *)callbackBlock:(id<KtKotlinSuspendFunction1>)block __attribute__((swift_name("callback(block:)")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("LibraryKt")))
|
||||
@interface KtLibraryKt : KtBase
|
||||
|
||||
@@ -1033,6 +1033,22 @@ __attribute__((swift_name("Kt54119Kt")))
|
||||
+ (BOOL)callContainsEntryMap:(NSDictionary<id, id> *)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<KtKotlinKSuspendFunction1>)getFillFunction __attribute__((swift_name("getFillFunction()")));
|
||||
+ (NSArray<KtInt *> *)callbackBlock:(id<KtKotlinSuspendFunction1>)block __attribute__((swift_name("callback(block:)")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("LibraryKt")))
|
||||
@interface KtLibraryKt : KtBase
|
||||
|
||||
@@ -1033,6 +1033,22 @@ __attribute__((swift_name("Kt54119Kt")))
|
||||
+ (BOOL)callContainsEntryMap:(NSDictionary<id, id> *)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<KtKotlinKSuspendFunction1>)getFillFunction __attribute__((swift_name("getFillFunction()")));
|
||||
+ (NSArray<KtInt *> *)callbackBlock:(id<KtKotlinSuspendFunction1>)block __attribute__((swift_name("callback(block:)")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("LibraryKt")))
|
||||
@interface KtLibraryKt : KtBase
|
||||
|
||||
@@ -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<Int>.fill() {
|
||||
yield(1)
|
||||
yield(2)
|
||||
}
|
||||
|
||||
fun getFillFunction() = SequenceScope<Int>::fill
|
||||
|
||||
fun callback(block: suspend SequenceScope<Int>.() -> Unit) : List<Int> {
|
||||
return sequence {
|
||||
block()
|
||||
}.toList()
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user