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) {
21562156 if (fnType->isAsync () &&
21572157 !(isa<AbstractFunctionDecl>(dc) &&
21582158 cast<AbstractFunctionDecl>(dc)->hasAsync ())) {
2159- auto func = cast<AbstractFunctionDecl>(dc);
21602159 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+ }
21622163 }
21632164 }
21642165 }
Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ func acceptAutoclosureNonAsyncBad(_: @autoclosure () async -> Int) { }
4040// expected-error@-1{{'async' autoclosure parameter in a non-'async' function}}
4141// expected-note@-2{{add 'async' to function 'acceptAutoclosureNonAsyncBad' to make it asynchronous}}
4242
43+ struct HasAsyncBad {
44+ init ( _: @autoclosure ( ) async -> Int ) { }
45+ // expected-error@-1{{'async' autoclosure parameter in a non-'async' function}}
46+ }
47+
4348func testAutoclosure( ) async {
4449 __await acceptAutoclosureAsync( getInt ( ) ) // expected-error{{call is 'async' in an autoclosure argument is not marked with 'await'}}
4550 __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