Skip to content

Commit d82b836

Browse files
authored
Merge pull request swiftlang#71480 from xedin/rdar-121415906
[Concurrency] Synchronous witness of an async isolated requirement sh…
2 parents 98b285b + f6e0218 commit d82b836

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,6 +3102,12 @@ ConformanceChecker::checkActorIsolation(ValueDecl *requirement,
31023102
break;
31033103
}
31043104

3105+
// Witnessing `async` requirement with an isolated synchronous
3106+
// declaration is done via async witness thunk which requires
3107+
// a hop to the expected concurrency domain.
3108+
if (isAsyncDecl(requirement) && !isAsyncDecl(witness))
3109+
return refResult.isolation;
3110+
31053111
// Otherwise, we're done.
31063112
return llvm::None;
31073113

test/Concurrency/issue62394.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-silgen -verify %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -disable-availability-checking -emit-silgen -verify -strict-concurrency=complete %s | %FileCheck %s
3+
4+
// REQUIRES: objc_interop
5+
// REQUIRES: concurrency
6+
7+
@MainActor
8+
protocol P {
9+
func test() async
10+
}
11+
12+
struct S : P {
13+
func test() {}
14+
}
15+
16+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s10issue623941SVAA1PA2aDP4testyyYaFTW : $@convention(witness_method: P) @async (@in_guaranteed S) -> ()
17+
// CHECK: [[MAIN_ACTOR:%.*]] = begin_borrow {{.*}} : $MainActor
18+
// CHECK-NEXT: hop_to_executor [[MAIN_ACTOR]] : $MainActor
19+
// CHECK: [[SELF:%.*]] = load [trivial] %0 : $*S
20+
// CHECK: [[TEST_FN:%.*]] = function_ref @$s10issue623941SV4testyyF : $@convention(method) (S) -> ()
21+
// CHECK-NEXT: {{.*}} = apply [[TEST_FN]]([[SELF]]) : $@convention(method) (S) -> ()

0 commit comments

Comments
 (0)