Start detangling the uses of TypeDecl::getProtocols(). NFC

Getting the protocols of an arbitrary type doesn't make sense, so start phasing this out by introducing specialized entry points that do make sense:
  - get the inherited protocols of a ProtocolDecl
  - get the conforming protocols for an associated type or generic
  type parameter
  - (already present) ask for the protocols to which a nominal type conforms

Swift SVN r26411
This commit is contained in:
Doug Gregor
2015-03-22 12:35:17 +00:00
parent 0d5bdd3774
commit f50ef5005c
9 changed files with 49 additions and 34 deletions

View File

@@ -2134,7 +2134,7 @@ public:
// Reference conformances for refined protocols.
auto protocol = Conformance->getProtocol();
for (auto base : protocol->getProtocols())
for (auto base : protocol->getInheritedProtocols(nullptr))
emitBaseProtocolWitness(base);
// Emit witnesses in protocol declaration order.
@@ -2292,7 +2292,8 @@ public:
witness.getReplacement()->getCanonicalType()});
// Emit records for the protocol requirements on the type.
assert(td->getProtocols().size() == witness.getConformances().size()
assert(td->getConformingProtocols(nullptr).size()
== witness.getConformances().size()
&& "number of conformances in assoc type substitution do not match "
"number of requirements on assoc type");
// The conformances should be all null or all nonnull.
@@ -2309,8 +2310,9 @@ public:
return !C;
})));
for (unsigned i = 0, e = td->getProtocols().size(); i < e; ++i) {
auto protocol = td->getProtocols()[i];
for (unsigned i = 0, e = td->getConformingProtocols(nullptr).size(); i < e;
++i) {
auto protocol = td->getConformingProtocols(nullptr)[i];
// Only reference the witness if the protocol requires it.
if (!SGM.Types.protocolRequiresWitnessTable(protocol))