Skip to content

Commit 0c5bfc2

Browse files
authored
Merge pull request #60667 from DougGregor/witness-thunk-accessible-from-anywhere
2 parents 593c6a3 + d081251 commit 0c5bfc2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,6 +3083,11 @@ Optional<ActorIsolation> ConformanceChecker::checkActorIsolation(
30833083
diagnoseNonSendableTypesInReference(
30843084
getConcreteWitness(), DC, loc, SendableCheckReason::Conformance);
30853085

3086+
// If the witness is accessible across actors, we don't need to consider it
3087+
// isolated.
3088+
if (isAccessibleAcrossActors(witness, refResult.isolation, DC))
3089+
return None;
3090+
30863091
if (refResult.isolation.isActorIsolated() && isAsyncDecl(requirement) &&
30873092
!isAsyncDecl(witness))
30883093
return refResult.isolation;

test/SILGen/async_conversion.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ struct X: P {
2121
// CHECK: function_ref @$s4test1XV1fySSSgSi_SStF : $@convention(method) (Int, @guaranteed String, X) -> @owned Optional<String>
2222
func f(_: Int, _: String) -> String? { nil }
2323
}
24+
25+
protocol P2 {
26+
init() async
27+
}
28+
29+
actor A: P2 {
30+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s4test1ACAA2P2A2aDPxyYacfCTW
31+
// CHECK-NOT: hop_to_executor
32+
// CHECK: function_ref @$s4test1ACACycfC : $@convention(method) (@thick A.Type) -> @owned A // user: %3
33+
// CHECK-NEXT: apply
34+
// CHECK: return
35+
}

0 commit comments

Comments
 (0)