Skip to content

Commit 97ced42

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

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/Sema/TypeCheckType.cpp

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

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

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

test/Concurrency/isolated_parameters.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,18 @@ 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+
}
401+
extension A2 {
402+
nonisolated func f() async {
403+
await { (self: isolated Self) in }(self)
404+
}
405+
}
406+
407+
@MainActor class MA2 {}
408+
extension MA2 {
409+
nonisolated func f() async {
410+
await { (self: isolated Self) in }(self)
411+
}
412+
}

0 commit comments

Comments
 (0)