File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1407,6 +1407,12 @@ namespace {
14071407 }
14081408 }
14091409
1410+ // "Defer" blocks are treated as if they are in their enclosing context.
1411+ if (auto func = dyn_cast<FuncDecl>(dc)) {
1412+ if (func->isDeferBody ())
1413+ continue ;
1414+ }
1415+
14101416 // Check isolation of the context itself. We do this separately
14111417 // from the closure check because closures capture specific variables
14121418 // while general isolation is declaration-based.
Original file line number Diff line number Diff line change @@ -834,3 +834,16 @@ func test_invalid_reference_to_actor_member_without_a_call_note() {
834834 }
835835 }
836836}
837+
838+ // Actor isolation and "defer"
839+ actor Counter {
840+ var counter : Int = 0
841+
842+ func next( ) -> Int {
843+ defer {
844+ counter = counter + 1
845+ }
846+
847+ return counter
848+ }
849+ }
You can’t perform that action at this time.
0 commit comments