Skip to content

Commit 2a01301

Browse files
committed
Allow functions marked @LLDBDebuggerFunction to bypass actor isolation checks
In order to allow LLDB to evaluate expressions inside an actor without spawining async functions and potentially continue all threads, this relaxes the actor isolation checks in @LLDBDebuggerFunction functions to allow a synchronous call into an extension method. rdar://75905336 (cherry picked from commit 93449728b9b7aaf84ad69ed1d0d7785cd825e0d6)
1 parent 8233797 commit 2a01301

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,10 @@ void swift::checkTopLevelActorIsolation(TopLevelCodeDecl *decl) {
23292329
}
23302330

23312331
void swift::checkFunctionActorIsolation(AbstractFunctionDecl *decl) {
2332+
// Disable this check for @LLDBDebuggerFunction functions.
2333+
if (decl->getAttrs().hasAttribute<LLDBDebuggerFunctionAttr>())
2334+
return;
2335+
23322336
ActorIsolationChecker checker(decl);
23332337
if (auto body = decl->getBody()) {
23342338
body->walk(checker);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -debugger-support
2+
// REQUIRES: concurrency
3+
4+
// This test simulates LLDB's expression evaluator makeing an otherwise illegal
5+
// synchronous call into an extension of an actor, as it would to run `p n` in
6+
// this example.
7+
8+
actor A {
9+
var n : Int = 0
10+
}
11+
12+
extension A {
13+
final func lldb_wrapped_expr() {
14+
n = 1
15+
}
16+
}
17+
18+
@LLDBDebuggerFunction
19+
func lldb_expr(a: A) {
20+
a.lldb_wrapped_expr()
21+
}

0 commit comments

Comments
 (0)