File tree 1 file changed +44
-0
lines changed
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,50 @@ readonly
341
341
eliminated, but cannot be reordered or folded in a way that would
342
342
move calls to the readnone function across side effects.
343
343
344
+ releasenone
345
+
346
+ function has side effects, it can read or write global state, or state
347
+ reachable from its arguments. It can however be assumed that no externally
348
+ visible release has happened (i.e it is allowed for a ``releasenone ``
349
+ function to allocate and destruct an object in its implementation as long as
350
+ this is does not cause an release of an object visible outside of the
351
+ implementation).
352
+
353
+ Examples
354
+ ::
355
+ class SomeObject {
356
+ final var x: Int = 3
357
+ }
358
+ var global = SomeObject()
359
+
360
+ class SomeOtherObject {
361
+ var x: Int = 2
362
+ deinit {
363
+ global = SomeObject()
364
+ }
365
+ }
366
+
367
+ @effects(releasenone)
368
+ func validReleaseNoneFunction(x: Int) -> Int {
369
+ global.x = 5
370
+ return x + 2
371
+ }
372
+
373
+ @effects(releasenone)
374
+ func validReleaseNoneFunction(x: Int) -> Int {
375
+ var notExternallyVisibleObject = SomeObject()
376
+ return x + notExternallyVisibleObject.x
377
+ }
378
+
379
+ func notAReleaseNoneFunction(x: Int, y: SomeObject) -> Int {
380
+ return x + y.x
381
+ }
382
+
383
+ func notAReleaseNoneFunction(x: Int) -> Int {
384
+ var releaseExternallyVisible = SomeOtherObject()
385
+ return x + releaseExternallyVisible.x
386
+ }
387
+
344
388
readwrite
345
389
346
390
function has side effects and the optimizer can't assume anything.
You can’t perform that action at this time.
0 commit comments