mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Diagnostics] Improve diagnostics when passing async to a sync parameter
If `async` effect has been inferred from the body of the closure, let's find out the first occurrence of `async` node and point it out to make it clear why closure is `async`. Resolves: rdar://70610141
This commit is contained in:
@@ -33,9 +33,9 @@ func missingTryInBlock<T : AsyncSequence>(_ seq: T) {
|
||||
|
||||
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
|
||||
func missingAsyncInBlock<T : AsyncSequence>(_ seq: T) {
|
||||
execute { // expected-error{{invalid conversion from 'async' function of type '() async -> Void' to synchronous function type '() -> Void'}}
|
||||
execute { // expected-error{{cannot pass function of type '() async -> Void' to parameter expecting synchronous function type}}
|
||||
do {
|
||||
for try await _ in seq { }
|
||||
for try await _ in seq { } // expected-note {{'async' in a closure that does not support concurrency}}
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
@@ -81,4 +81,4 @@ func forAwaitWithConcreteType(_ seq: ThrowingAsyncSequence) throws { // expected
|
||||
for try await elt in seq { // expected-error {{'async' in a function that does not support concurrency}}
|
||||
_ = elt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user