Commits

Doug Gregor committed a012f60633a
Make protocol methods generic over <Self>. Pull the implicit 'Self' associated type out of the protocol and into an implicitly-declared generic parameter list for the protocol. This makes all of the methods of a protocol polymorphic, e.g., given protocol P { typealias Assoc func getAssoc() -> Assoc } the type of P.getAssoc is: <Self : P> (self : @inout P) -> () -> Self.Assoc This directly expresses the notion that protocol methods are polymorphic, even though 'Self' is always implicitly bound. It can be used to simplify IRgen and some parts of the type checker, as well as laying more of the groundwork for default definitions within protocols as well as sundry other improvements to the generics system. There are a number of moving parts that needed to be updated in tandem for this. In no particular order: - Protocols always get an implicit generic parameter list, with a single generic parameter 'Self' that conforms to the protocol itself. - The 'Self' archetype type now knows which protocol it is associated with (since we can no longer point it at the Self associated type declaration). - Protocol methods now get interface types (i.e., canonicalizable dependent function types). - The "all archetypes" list for a polymorphic function type does not include the Self archetype nor its nested types, because they are handled implicitly. This avoids the need to rework IRGen's handling of archetypes for now. - When (de-)serializing a XREF for a function type that has an interface type, use the canonicalized interface type, which can be meaningfully compared during deserialization (unlike the PolymorphicFunctionType we'd otherwise be dealing with). - Added a SIL-specific type attribute @sil_self, which extracts the 'Self' archetype of a protocol, because we can no longer refer to the associated type "P.Self". Swift SVN r9066