Skip to content

Commit 511add6

Browse files
committed
[NFC][Concurrency] Add a test case for non-escaping, synchronous closures
used inside a function with an isolated parameter.
1 parent 68a4b31 commit 511add6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/Concurrency/isolated_parameters.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,18 @@ func execute<ActorType: Actor>(
333333
task(isolatedActor)
334334
}
335335
}
336+
337+
actor ProtectsDictionary {
338+
var dictionary: [String: String] = ["A": "B"]
339+
}
340+
341+
func getValues(
342+
forKeys keys: [String],
343+
from actor: isolated ProtectsDictionary
344+
) -> [String?] {
345+
// A non-escaping, synchronous closure cannot cross isolation
346+
// boundaries; it should be isolated to 'actor'.
347+
keys.map { key in
348+
actor.dictionary[key]
349+
}
350+
}

0 commit comments

Comments
 (0)