@@ -62,3 +62,96 @@ class TestClass {
62
62
@available ( * , noasync)
63
63
deinit { }
64
64
}
65
+
66
+ @available ( SwiftStdlib 5 . 5 , * )
67
+ func test_defers_sync( ) {
68
+ defer {
69
+ defer { basicNoAsync ( ) }
70
+ basicNoAsync ( )
71
+ }
72
+
73
+ func local_sync_func( ) {
74
+ defer { basicNoAsync ( ) }
75
+ _ = ( )
76
+ }
77
+
78
+ func local_async_func( ) async {
79
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
80
+ defer { basicNoAsync ( ) }
81
+ _ = ( )
82
+ }
83
+
84
+ let local_sync_closure = { ( ) -> Void in
85
+ defer { basicNoAsync ( ) }
86
+ _ = ( )
87
+ }
88
+ _ = local_sync_closure
89
+
90
+ // local async closure
91
+ let local_async_closure = { ( ) async -> Void in
92
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
93
+ defer { basicNoAsync ( ) }
94
+ _ = ( )
95
+ }
96
+ _ = local_async_closure
97
+
98
+ var local_sync_var : Void {
99
+ defer { basicNoAsync ( ) }
100
+ return ( )
101
+ }
102
+
103
+ var local_async_var : Void {
104
+ get async {
105
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
106
+ defer { basicNoAsync ( ) }
107
+ return ( )
108
+ }
109
+ }
110
+ }
111
+
112
+ @available ( SwiftStdlib 5 . 5 , * )
113
+ func test_defer_async( ) async {
114
+ defer {
115
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
116
+ defer { basicNoAsync ( ) }
117
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
118
+ basicNoAsync ( )
119
+ }
120
+
121
+ func local_sync_func( ) {
122
+ defer { basicNoAsync ( ) }
123
+ _ = ( )
124
+ }
125
+
126
+ func local_async_func( ) async {
127
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
128
+ defer { basicNoAsync ( ) }
129
+ _ = ( )
130
+ }
131
+
132
+ let local_sync_closure = { ( ) -> Void in
133
+ defer { basicNoAsync ( ) }
134
+ _ = ( )
135
+ }
136
+ _ = local_sync_closure
137
+
138
+ let local_async_closure = { ( ) async -> Void in
139
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
140
+ defer { basicNoAsync ( ) }
141
+ _ = ( )
142
+ }
143
+ _ = local_async_closure
144
+
145
+ var local_sync_var : Void {
146
+ defer { basicNoAsync ( ) }
147
+ return ( )
148
+ }
149
+
150
+ var local_async_var : Void {
151
+ get async {
152
+ // expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode}}
153
+ defer { basicNoAsync ( ) }
154
+ return ( )
155
+ }
156
+ }
157
+ }
0 commit comments