File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -3277,7 +3277,8 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
3277
3277
// the autoclosure expression itself, and the autoclosure must be
3278
3278
// 'async'.
3279
3279
3280
- // FIXME: 'unsafe' should do what with autoclosures?
3280
+ OldFlags.mergeFrom (ContextFlags::HasAnyUnsafe, Self.Flags );
3281
+ OldFlags.mergeFrom (ContextFlags::HasAnyUnsafeSite, Self.Flags );
3281
3282
}
3282
3283
3283
3284
void setCoverageForSingleValueStmtExpr () {
Original file line number Diff line number Diff line change @@ -131,8 +131,18 @@ func testKeyPath() {
131
131
_ = unsafe \HasProperties . computedUnsafe
132
132
}
133
133
134
+ func takesAutoclosure< T> ( _ body: @autoclosure ( ) -> T ) { }
135
+
136
+ func testAutoclosure( ) {
137
+ // expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{20-20=unsafe }}
138
+ takesAutoclosure ( unsafeFunction ( ) ) // expected-note{{reference to unsafe global function 'unsafeFunction()'}}
139
+
140
+ unsafe takesAutoclosure( unsafeFunction ( ) )
141
+
142
+ takesAutoclosure ( unsafe unsafeFunction( ) )
143
+ }
144
+
134
145
// Parsing of `unsafe` expressions.
135
146
func testUnsafePositionError( ) -> Int {
136
147
return 3 + unsafe unsafeInt( ) // expected-error{{'unsafe' cannot appear to the right of a non-assignment operator}}
137
148
}
138
-
You can’t perform that action at this time.
0 commit comments