Remove potential for duplicate diagnosis on rethrows

This commit is contained in:
Philippe Hausler
2021-02-04 13:18:27 -08:00
parent 9a3d613345
commit 00f6af1372
2 changed files with 30 additions and 0 deletions

View File

@@ -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()
}