mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is a follow-up to https://github.com/swiftlang/swift/pull/82085 which made it so async variant doesn't get `@Sendable` inferred because the proposal specified that inference should happen only on completion handler parameter type of a synchronous variant of an imported API. This runs into implementation issues related to thunking in some cases were async convention expects the type of a completion handler to match exactly for both variants of the imported API. Resolves: rdar://154695053
38 lines
1.6 KiB
Swift
38 lines
1.6 KiB
Swift
// RUN: %empty-directory(%t/src)
|
|
// RUN: split-file %s %t/src
|
|
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-sil %t/src/main.swift \
|
|
// RUN: -import-objc-header %t/src/Test.h \
|
|
// RUN: -swift-version 6 \
|
|
// RUN: -module-name main -I %t -verify | %FileCheck %t/src/main.swift
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
// rdar://154695053
|
|
|
|
//--- Test.h
|
|
|
|
@import Foundation;
|
|
|
|
@interface Test <NSObject>
|
|
+(void) compute: (void (^)(void)) completion;
|
|
@end
|
|
|
|
//--- main.swift
|
|
|
|
func test(v: Test.Type) async {
|
|
_ = await v.compute()
|
|
}
|
|
|
|
// CHECK-LABEL: sil hidden @$s4main4test1vySo4TestCm_tYaF : $@convention(thin) @async (@thick Test.Type) -> ()
|
|
// CHECK: [[TEST_TYPE:%.*]] = thick_to_objc_metatype %0 to $@objc_metatype Test.Type
|
|
// CHECK: [[METHOD:%.*]] = objc_method %5, #Test.compute!foreign : (Test.Type) -> () async -> (), $@convention(objc_method) (Optional<@convention(block) @Sendable () -> ()>, @objc_metatype Test.Type) -> ()
|
|
// CHECK: [[BLOCK:%.*]] = alloc_stack $@block_storage Any
|
|
// CHECK: [[COMPLETION_HANDLER:%.*]] = function_ref @$sIeyBh_ytTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> ()
|
|
// CHECK: [[HEADER:%.*]] = init_block_storage_header [[BLOCK]], invoke [[COMPLETION_HANDLER]]
|
|
// CHECK: [[OPTIONAL_HEADER:%.*]] = enum $Optional<@convention(block) @Sendable () -> ()>, #Optional.some!enumelt, [[HEADER]]
|
|
// CHECK: {{.*}} = apply [[METHOD]]([[OPTIONAL_HEADER]], [[TEST_TYPE]])
|
|
// CHECK: } // end sil function '$s4main4test1vySo4TestCm_tYaF'
|
|
|
|
// CHECK-LABEL: sil shared [transparent] [thunk] @$sIeyBh_ytTz_ : $@convention(c) @Sendable (@inout_aliasable @block_storage Any) -> ()
|