/// Add the requirements for the given potential archetype and its nested /// potential archetypes to the set of requirements. static void addRequirements( Module &mod, Type type, ArchetypeBuilder::PotentialArchetype *pa, llvm::SmallPtrSet<ArchetypeBuilder::PotentialArchetype *, 16> &knownPAs, SmallVectorImpl<Requirement> &requirements) { // If the potential archetype has been bound away to a concrete type, // it needs no requirements. if (pa->isConcreteType()) return; // Add a value witness marker. requirements.push_back(Requirement(RequirementKind::WitnessMarker, type, Type())); // Add superclass requirement, if needed. if (auto superclass = pa->getSuperclass()) { // FIXME: Distinguish superclass from conformance? // FIXME: What if the superclass type involves a type parameter? requirements.push_back(Requirement(RequirementKind::Conformance, type, superclass)); } // Add conformance requirements. SmallVector<ProtocolDecl *, 4> protocols; for (const auto &conforms : pa->getConformsTo()) { protocols.push_back(conforms.first); } ProtocolType::canonicalizeProtocols(protocols); for (auto proto : protocols) { requirements.push_back(Requirement(RequirementKind::Conformance, type, proto->getDeclaredType())); } }