Skip to content

Allow functions marked @LLDBDebuggerFunction to bypass actor isolatio… #37198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,10 @@ void swift::checkTopLevelActorIsolation(TopLevelCodeDecl *decl) {
}

void swift::checkFunctionActorIsolation(AbstractFunctionDecl *decl) {
// Disable this check for @LLDBDebuggerFunction functions.
if (decl->getAttrs().hasAttribute<LLDBDebuggerFunctionAttr>())
return;

ActorIsolationChecker checker(decl);
if (auto body = decl->getBody()) {
body->walk(checker);
Expand Down
21 changes: 21 additions & 0 deletions test/Concurrency/LLDBDebuggerFunctionActorExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -debugger-support
// REQUIRES: concurrency

// This test simulates LLDB's expression evaluator makeing an otherwise illegal
// synchronous call into an extension of an actor, as it would to run `p n` in
// this example.

actor A {
var n : Int = 0
}

extension A {
final func lldb_wrapped_expr() {
n = 1
}
}

@LLDBDebuggerFunction
func lldb_expr(a: A) {
a.lldb_wrapped_expr()
}