File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend %s -emit-sil \
2
+ // RUN: -o /dev/null \
3
+ // RUN: -verify \
4
+ // RUN: -sil-verify-all \
5
+ // RUN: -module-name test \
6
+ // RUN: -disable-experimental-parser-round-trip \
7
+ // RUN: -enable-experimental-feature NonescapableTypes
8
+
9
+ // REQUIRES: asserts
10
+ // REQUIRES: swift_in_compiler
11
+
12
+ struct NCInt : ~ Copyable {
13
+ var value : Int
14
+
15
+ init ( _ value: Int ) { self . value = value }
16
+ }
17
+
18
+ @_nonescapable
19
+ struct NEInt /*: ~Escapable*/ {
20
+ let value : Int
21
+
22
+ init ( borrowed: borrowing NCInt ) -> _borrow( borrowed) Self {
23
+ self . value = borrowed. value
24
+ return self
25
+ }
26
+ }
27
+
28
+ extension NCInt {
29
+ var neInt : NEInt {
30
+ borrowing get {
31
+ NEInt ( borrowed: self )
32
+ }
33
+ }
34
+ }
35
+
36
+ func ncint_get_neint_mutable_local( ) {
37
+ var ncInt = NCInt ( 731 )
38
+ do {
39
+ // Begin read access ncInt
40
+ var neInt = ncInt. neInt
41
+
42
+ // Capture neInt in a nonescapable closure.
43
+ assert ( ncInt. value == neInt. value)
44
+ // End read access ncInt
45
+
46
+ // Begin read access ncInt
47
+ // Fully reassign neInt
48
+ neInt = ncInt. neInt
49
+ // Destroy neInt
50
+ // End read access ncInt
51
+ }
52
+ ncInt. value = 1
53
+ }
You can’t perform that action at this time.
0 commit comments