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 {
1407
1407
}
1408
1408
}
1409
1409
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
+
1410
1416
// Check isolation of the context itself. We do this separately
1411
1417
// from the closure check because closures capture specific variables
1412
1418
// 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() {
834
834
}
835
835
}
836
836
}
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