mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove potential for duplicate diagnosis on rethrows
This commit is contained in:
@@ -31,4 +31,27 @@ func missingAsyncInBlock<T : AsyncSequence>(_ seq: T) {
|
||||
for try await _ in seq { }
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
|
||||
func doubleDiagCheckGeneric<T : AsyncSequence>(_ seq: T) async {
|
||||
var it = seq.makeAsyncIterator()
|
||||
// expected-note@+2{{call is to 'rethrows' function, but a conformance has a throwing witness}}
|
||||
// expected-error@+1{{call can throw, but it is not marked with 'try' and the error is not handled}}
|
||||
let _ = await it.next()
|
||||
}
|
||||
|
||||
struct ThrowingAsyncSequence: AsyncSequence, AsyncIteratorProtocol {
|
||||
typealias Element = Int
|
||||
typealias AsyncIterator = Self
|
||||
mutating func next() async throws -> Int? {
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeAsyncIterator() -> Self { return self }
|
||||
}
|
||||
|
||||
func doubleDiagCheckConcrete(_ seq: ThrowingAsyncSequence) async {
|
||||
var it = seq.makeAsyncIterator()
|
||||
// expected-error@+1{{call can throw, but it is not marked with 'try' and the error is not handled}}
|
||||
let _ = await it.next()
|
||||
}
|
||||
Reference in New Issue
Block a user