|
| 1 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -swift-version 6 -enable-upcoming-feature NonisolatedNonsendingByDefault -verify %s | %FileCheck %s |
| 2 | + |
| 3 | +// REQUIRES: swift_feature_NonisolatedNonsendingByDefault |
| 4 | + |
| 5 | +// REQUIRES: concurrency |
| 6 | +// REQUIRES: objc_interop |
| 7 | + |
| 8 | +import Foundation |
| 9 | + |
| 10 | +class Test: NSObject { |
| 11 | + |
| 12 | + // CHECK: // Test.testExplicit(_:) |
| 13 | + // CHECK-NEXT: // Isolation: caller_isolation_inheriting |
| 14 | + // CHECK-LABEL: sil hidden [ossa] @$s27nonisolated_nonsending_objc4TestC12testExplicityyySSYbcYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @callee_guaranteed (@guaranteed String) -> (), @guaranteed Test) -> () |
| 15 | + |
| 16 | + // CHECK: // @objc Test.testExplicit(_:) |
| 17 | + // CHECK-NEXT: // Isolation: caller_isolation_inheriting |
| 18 | + // CHECK-LABEL: sil private [thunk] [ossa] @$s27nonisolated_nonsending_objc4TestC12testExplicityyySSYbcYaFTo : $@convention(objc_method) (@convention(block) @Sendable (NSString) -> (), @convention(block) () -> (), Test) -> () |
| 19 | + |
| 20 | + // @objc closure #1 in Test.testExplicit(_:) |
| 21 | + // CHECK-LABEL: sil shared [thunk] [ossa] @$s27nonisolated_nonsending_objc4TestC12testExplicityyySSYbcYaFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable (NSString) -> (), @convention(block) () -> (), Test) -> () { |
| 22 | + // CHECK: [[ACTOR:%.*]] = enum $Optional<any Actor>, #Optional.none!enumelt |
| 23 | + // CHECK: [[BUILTIN_ACTOR:%.*]] = unchecked_value_cast [[ACTOR]] to $Builtin.ImplicitActor |
| 24 | + // CHECK: [[TEST_EXPLICIT_REF:%.*]] = function_ref @$s27nonisolated_nonsending_objc4TestC12testExplicityyySSYbcYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @callee_guaranteed (@guaranteed String) -> (), @guaranteed Test) -> () |
| 25 | + // CHECK-NEXT: apply [[TEST_EXPLICIT_REF]]([[BUILTIN_ACTOR]], {{.*}}) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @callee_guaranteed (@guaranteed String) -> (), @guaranteed Test) -> () |
| 26 | + // CHECK: } // end sil function '$s27nonisolated_nonsending_objc4TestC12testExplicityyySSYbcYaFyyYacfU_To' |
| 27 | + @objc nonisolated(nonsending) func testExplicit(_: @Sendable @escaping (String) -> Void) async { |
| 28 | + } |
| 29 | + |
| 30 | + // CHECK: // Test.testImplicit(_:) |
| 31 | + // CHECK-NEXT: // Isolation: caller_isolation_inheriting |
| 32 | + // CHECK-LABEL: sil hidden [ossa] @$s27nonisolated_nonsending_objc4TestC12testImplicityyySSYbcYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @callee_guaranteed (@guaranteed String) -> (), @guaranteed Test) -> () |
| 33 | + |
| 34 | + // CHECK: // @objc Test.testImplicit(_:) |
| 35 | + // CHECK-NEXT: // Isolation: caller_isolation_inheriting |
| 36 | + // CHECK-LABEL: sil private [thunk] [ossa] @$s27nonisolated_nonsending_objc4TestC12testImplicityyySSYbcYaFTo : $@convention(objc_method) (@convention(block) @Sendable (NSString) -> (), @convention(block) () -> (), Test) -> () |
| 37 | + |
| 38 | + // @objc closure #1 in Test.testImplicit(_:) |
| 39 | + // CHECK-LABEL: sil shared [thunk] [ossa] @$s27nonisolated_nonsending_objc4TestC12testImplicityyySSYbcYaFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable (NSString) -> (), @convention(block) () -> (), Test) -> () { |
| 40 | + // CHECK: [[ACTOR:%.*]] = enum $Optional<any Actor>, #Optional.none!enumelt |
| 41 | + // CHECK: [[BUILTIN_ACTOR:%.*]] = unchecked_value_cast [[ACTOR]] to $Builtin.ImplicitActor |
| 42 | + // CHECK: [[TEST_IMPLICIT_REF:%.*]] = function_ref @$s27nonisolated_nonsending_objc4TestC12testImplicityyySSYbcYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @callee_guaranteed (@guaranteed String) -> (), @guaranteed Test) -> () |
| 43 | + // CHECK-NEXT: apply [[TEST_IMPLICIT_REF]]([[BUILTIN_ACTOR]], {{.*}}) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @callee_guaranteed (@guaranteed String) -> (), @guaranteed Test) -> () |
| 44 | + // CHECK: } // end sil function '$s27nonisolated_nonsending_objc4TestC12testImplicityyySSYbcYaFyyYacfU_To' |
| 45 | + @objc func testImplicit(_: @Sendable @escaping (String) -> Void) async { |
| 46 | + } |
| 47 | +} |
0 commit comments