Skip to content

Commit 8ea8a99

Browse files
committed
[AST] Make sure that nonisolated(nonsending) works together with @autoclosure
1 parent c3ea303 commit 8ea8a99

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9206,6 +9206,7 @@ void ParamDecl::setTypeRepr(TypeRepr *repr) {
92069206
dyn_cast<CallerIsolatedTypeRepr>(unwrappedType)) {
92079207
setCallerIsolated(true);
92089208
unwrappedType = callerIsolated->getBase();
9209+
continue;
92099210
}
92109211

92119212
break;

test/Concurrency/attr_execution/nonisolated_cross_module_with_flag_enabled.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public struct InferenceTest {
4040
public func testNested(callback: @escaping (@Sendable () async -> Void) -> Void) {}
4141
// CHECK: public func testNested(dict: [Swift.String : (nonisolated(nonsending) () async -> Swift.Void)?])
4242
public func testNested(dict: [String: (() async -> Void)?]) {}
43+
44+
// CHECK: nonisolated(nonsending) public func testAutoclosure(value1 fn: nonisolated(nonsending) @autoclosure () async -> Swift.Int) async
45+
public func testAutoclosure(value1 fn: @autoclosure () async -> Int) async { await fn() }
46+
// CHECK: nonisolated(nonsending) public func testAutoclosure(value2 fn: nonisolated(nonsending) @autoclosure () async -> Swift.Int) async
47+
public func testAutoclosure(value2 fn: nonisolated(nonsending) @autoclosure () async -> Int) async { await fn() }
4348
}
4449

4550
//--- Client.swift
@@ -78,3 +83,12 @@ func testInference(t: InferenceTest) async {
7883
t.testNested { _ in }
7984
t.testNested(dict: [:])
8085
}
86+
87+
// CHECK-LABEL: sil hidden @$s6Client15testAutoclosure1ty1A13InferenceTestV_tYaF : $@convention(thin) @async (@in_guaranteed InferenceTest) -> ()
88+
// CHECK: function_ref @$s1A13InferenceTestV15testAutoclosure6value1ySiyYaYCXK_tYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> Int, @in_guaranteed InferenceTest) -> ()
89+
// CHECK: function_ref @$s1A13InferenceTestV15testAutoclosure6value2ySiyYaYCXK_tYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> Int, @in_guaranteed InferenceTest) -> ()
90+
// CHECK: } // end sil function '$s6Client15testAutoclosure1ty1A13InferenceTestV_tYaF'
91+
func testAutoclosure(t: InferenceTest) async {
92+
await t.testAutoclosure(value1: 42)
93+
await t.testAutoclosure(value2: 42)
94+
}

0 commit comments

Comments
 (0)