Skip to content

Commit c2070c0

Browse files
authored
Merge pull request #85774 from xedin/rdar-164561176-6.3
[6.3][SILGen] Account for an implicit isolation parameter while emitting n…
2 parents ccbc0b7 + 167ef6a commit c2070c0

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,11 +1438,12 @@ emitObjCThunkArguments(SILGenFunction &SGF, SILLocation loc, SILDeclRef thunk,
14381438
// Bridge the input types.
14391439
assert(bridgedArgs.size() == nativeInputs.size() - bool(nativeInputsHasImplicitIsolatedParam));
14401440
for (unsigned i = 0, size = bridgedArgs.size(); i < size; ++i) {
1441+
unsigned nativeParamIndex = i + nativeInputsHasImplicitIsolatedParam;
14411442
// Consider the bridged values to be "call results" since they're coming
14421443
// from potentially nil-unsound ObjC callers.
14431444
ManagedValue native = SGF.emitBridgedToNativeValue(
14441445
loc, bridgedArgs[i], bridgedFormalTypes[i], nativeFormalTypes[i],
1445-
swiftFnTy->getParameters()[i].getSILStorageType(
1446+
swiftFnTy->getParameters()[nativeParamIndex].getSILStorageType(
14461447
SGF.SGM.M, swiftFnTy, SGF.getTypeExpansionContext()),
14471448
SGFContext(),
14481449
/*isCallResult*/ true);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

Comments
 (0)