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 @@ -1549,6 +1549,12 @@ namespace {
1549
1549
}
1550
1550
}
1551
1551
1552
+ // "Defer" blocks are treated as if they are in their enclosing context.
1553
+ if (auto func = dyn_cast<FuncDecl>(dc)) {
1554
+ if (func->isDeferBody ())
1555
+ continue ;
1556
+ }
1557
+
1552
1558
// Check isolation of the context itself. We do this separately
1553
1559
// from the closure check because closures capture specific variables
1554
1560
// while general isolation is declaration-based.
Original file line number Diff line number Diff line change @@ -845,3 +845,16 @@ func test_invalid_reference_to_actor_member_without_a_call_note() {
845
845
}
846
846
}
847
847
}
848
+
849
+ // Actor isolation and "defer"
850
+ actor Counter {
851
+ var counter : Int = 0
852
+
853
+ func next( ) -> Int {
854
+ defer {
855
+ counter = counter + 1
856
+ }
857
+
858
+ return counter
859
+ }
860
+ }
You can’t perform that action at this time.
0 commit comments