File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -2156,9 +2156,10 @@ static Type validateParameterType(ParamDecl *decl) {
2156
2156
if (fnType->isAsync () &&
2157
2157
!(isa<AbstractFunctionDecl>(dc) &&
2158
2158
cast<AbstractFunctionDecl>(dc)->hasAsync ())) {
2159
- auto func = cast<AbstractFunctionDecl>(dc);
2160
2159
decl->diagnose (diag::async_autoclosure_nonasync_function);
2161
- func->diagnose (diag::note_add_async_to_function, func->getName ());
2160
+ if (auto func = dyn_cast<FuncDecl>(dc)) {
2161
+ func->diagnose (diag::note_add_async_to_function, func->getName ());
2162
+ }
2162
2163
}
2163
2164
}
2164
2165
}
Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ func acceptAutoclosureNonAsyncBad(_: @autoclosure () async -> Int) { }
40
40
// expected-error@-1{{'async' autoclosure parameter in a non-'async' function}}
41
41
// expected-note@-2{{add 'async' to function 'acceptAutoclosureNonAsyncBad' to make it asynchronous}}
42
42
43
+ struct HasAsyncBad {
44
+ init ( _: @autoclosure ( ) async -> Int ) { }
45
+ // expected-error@-1{{'async' autoclosure parameter in a non-'async' function}}
46
+ }
47
+
43
48
func testAutoclosure( ) async {
44
49
__await acceptAutoclosureAsync( getInt ( ) ) // expected-error{{call is 'async' in an autoclosure argument is not marked with 'await'}}
45
50
__await acceptAutoclosureNonAsync( getInt ( ) ) // expected-error{{'async' in an autoclosure that does not support concurrency}}
You can’t perform that action at this time.
0 commit comments