Skip to content

Commit 4f728cd

Browse files
committed
Concurrency: Look through l-value types in ActorIsolation::getActor().
When computing the actor type for an expression, be sure to look through l-value types to get the underlying type. Resolves rdar://139470254.
1 parent c0d64ba commit 4f728cd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/AST/ActorIsolation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ NominalTypeDecl *ActorIsolation::getActor() const {
103103
if (auto *instance = actorInstance.dyn_cast<VarDecl *>()) {
104104
actorType = instance->getTypeInContext();
105105
} else if (auto *expr = actorInstance.dyn_cast<Expr *>()) {
106-
actorType = expr->getType();
106+
actorType = expr->getType()->getRValueType();
107107
}
108108

109109
if (actorType) {

test/Concurrency/isolated_parameters.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@ func preciseIsolated(a: isolated MyActor) async {
541541
}
542542
}
543543
544+
func testLValueIsolated() async {
545+
var a = A() // expected-warning {{variable 'a' was never mutated}}
546+
await sync(isolatedTo: a)
547+
}
548+
544549
@MainActor func fromMain(ns: NotSendable) async -> NotSendable {
545550
await pass(value: ns, isolation: MainActor.shared)
546551
}

0 commit comments

Comments
 (0)