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
Sema: Resolve type witnesses for conditional conformances early
This allows for correctly diagnosing references to default type witnesses
with unsatisfied requirements once we start realizing types in members.
This change also lays the groundwork for a special case of default type
witness resolution behavior when associated type collisions occur in the
presence of multiple regular and conditional conformances. Previously,
depending on evaluation order, a default type witness for a conditional
conformance could satisfy a type requirement for a regular conformance,
and the following snippet would have compiled:
protocol A { associatedtype X }
protocol B { associatedtype X = Bool }
struct Foo<T>: A {} // error: type 'Foo<T>' does not conform to protocol 'A'
extension Foo: B where T == Int {}
If the conditional requirements of a conformance are satisfied by those
of another conformance, default type witnesses for the former, more
general conformance, can now satisfy type requirements for the latter
conformance – but not vice versa – in case of associated type collisions.
For example, both conformances below will associate 'X' with a single type
witness synthesized for the less constrained conformance to B.
struct Foo<T>: B {
internal typealias X = Bool // synthesized!
}
extension Foo: A where T == Int {}
0 commit comments