Skip to content

Commit bf8c7cc

Browse files
authored
Add reference for @preconcurrency (#307)
Fixes: rdar://128206384
2 parents d3bb2ea + 275d1dd commit bf8c7cc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

TSPL.docc/ReferenceManual/Attributes.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,60 @@ can increase your binary size and adversely affect performance.
13041304
because of the larger symbol table slowing dyld down.
13051305
-->
13061306

1307+
### preconcurrency
1308+
1309+
Apply this attribute to a declaration,
1310+
to suppress strict concurrency checking.
1311+
You can apply this attribute
1312+
to the following kinds of declarations:
1313+
1314+
- Imports
1315+
- Structures, classes, and actors
1316+
- Enumerations and enumeration cases
1317+
- Protocols
1318+
- Variables and constants
1319+
- Subscripts
1320+
- Initializers
1321+
- Functions
1322+
1323+
On an import declaration,
1324+
this attribute reduces the strictness of concurrency checking
1325+
for code that uses types from the imported module.
1326+
Specifically,
1327+
types from the imported module
1328+
that aren't explicitly marked as nonsendable
1329+
can be used in a context that requires sendable types.
1330+
1331+
On other declarations,
1332+
this attribute reduces the strictness of concurrency checking
1333+
for code that uses the symbol being declared.
1334+
When you use this symbol in a scope that has minimal concurrency checking,
1335+
concurrency-related constraints specified by that symbol,
1336+
such as `Sendable` requirements or global actors,
1337+
aren't checked.
1338+
1339+
You can use this attribute as follows,
1340+
to aid in migrating code to strict concurrency checking:
1341+
1342+
1. Enable strict checking.
1343+
1. Annotate imports with the `preconcurrency` attribute
1344+
for modules that haven't enabled strict checking.
1345+
1. After migrating a module to strict checking,
1346+
remove the `preconcurrency` attribute.
1347+
The compiler warns you about
1348+
any places where the `preconcurrency` attribute on an import
1349+
no longer has an effect and should be removed.
1350+
1351+
For other declarations,
1352+
add the `preconcurrency` attribute
1353+
when you add concurrency-related constraints to the declaration,
1354+
if you still have clients
1355+
that haven't migrated to strict checking.
1356+
Remove the `preconcurrency` attribute after all your clients have migrated.
1357+
1358+
Declarations from Objective-C are always imported
1359+
as if they were marked with the `preconcurrency` attribute.
1360+
13071361
### propertyWrapper
13081362

13091363
Apply this attribute to a class, structure, or enumeration declaration

0 commit comments

Comments
 (0)