Skip to content

Commit 2ee2f1e

Browse files
authored
Merge pull request #77474 from tshortli/lvalue-expr-actor-isolation
Concurrency: Look through l-value types in `ActorIsolation::getActor()`
2 parents 20b85ed + 4f728cd commit 2ee2f1e

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)