You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Associated type inference] Limit Failure inference to rethrows next()
When inferring a type witness for `AsyncIteratorProtocol` or
`AsyncSequence`'s `Failure` associated type, don't infer from a
generic parameter named `Failure`. Instead, use `next()` as a cue: if
it `rethrows`, use `Failure` from one of the conformances; if it
`throws`, use `any Error`. This is a more conservative inference rule,
and addresses a failure to infer a `Failure` type witness for some
fairly-obvious cases.
Fixes rdar://122514816.
let _:Int= sf // expected-error{{cannot convert value of type 'S.Failure' (aka 'Never') to specified type 'Int'}}
52
80
let _:Int= tsf // expected-error{{cannot convert value of type 'TS.Failure' (aka 'any Error') to specified type 'Int'}}
53
-
let _:Int= gtsf1 // expected-error{{cannot convert value of type 'GenericTS<MyError>.Failure' (aka 'MyError') to specified type 'Int'}}
54
-
let _:Int= adapter // expected-error{{cannot convert value of type 'SequenceAdapter<GenericTS<MyError>>.Failure' (aka 'MyError') to specified type 'Int'}}
81
+
let _:Int= gtsf1 // expected-error{{cannot convert value of type 'GenericTS<MyError>.Failure' (aka 'any Error') to specified type 'Int'}}
82
+
let _:Int= adapter // expected-error{{cannot convert value of type 'SequenceAdapter<SpecificTS<MyError>>.Failure' (aka 'MyError') to specified type 'Int'}}
83
+
let _:Int= ntas // expected-error{{cannot convert value of type 'NormalThrowingAsyncSequence<String, MyError>.Failure' (aka 'any Error') to specified type 'Int'}}
// expected-error@-1{{thrown expression type 'OtherError' cannot be converted to error type 'MyError'}}
102
+
// expected-error@-1{{thrown expression type 'SpecificTS<OtherError>.AsyncIterator.Failure' (aka 'OtherError') cannot be converted to error type 'MyError'}}
0 commit comments