Skip to content

Commit dde017f

Browse files
committed
[Concurrency] allow isolated on dynamic self types
1 parent 6028bfb commit dde017f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4483,6 +4483,10 @@ TypeResolver::resolveIsolatedTypeRepr(IsolatedTypeRepr *repr,
44834483

44844484
Type type = resolveType(repr->getBase(), options);
44854485

4486+
if (auto ty = dyn_cast<DynamicSelfType>(type)) {
4487+
type = ty->getSelfType();
4488+
}
4489+
44864490
// isolated parameters must be of actor type
44874491
if (!type->hasTypeParameter() && !type->isAnyActorType() && !type->hasError()) {
44884492
// Optional actor types are fine - `nil` represents `nonisolated`.

test/Concurrency/isolated_parameters.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,10 @@ nonisolated func callFromNonisolated(ns: NotSendable) async {
395395
// expected-note@-2 {{calls to global function 'optionalIsolatedSync(_:to:)' from outside of its actor context are implicitly asynchronous}}
396396
// expected-complete-warning@-3 {{passing argument of non-sendable type 'NotSendable' into actor-isolated context may introduce data races}}
397397
}
398+
399+
actor A2 {}
400+
extension A2 {
401+
nonisolated func f() async {
402+
await { (self: isolated Self) in }(self)
403+
}
404+
}

0 commit comments

Comments
 (0)