SIL: SILModule::lookUpWitnessTable should always return a substitution list for generic conformances.

Even if the type is the DeclaredTypeInContext of the nominal, we still want the substitution list for generic specialization. Ideally the AST would always have a SpecializedProtocolConformance when we refer to a generic type instance, but our representation makes that difficult.

Swift SVN r12887
This commit is contained in:
Joe Groff
2014-01-23 23:45:32 +00:00
parent 081514b142
commit 3b132bdcc7

View File

@@ -75,6 +75,15 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C) {
const NormalProtocolConformance *NormalC
= cast<NormalProtocolConformance>(ParentC);
// If the normal conformance is for a generic type, and we didn't hit a
// specialized conformance, collect the substitutions from the generic type.
// FIXME: The AST should do this for us.
if (NormalC->getType()->isSpecialized() && Subs.empty()) {
Subs = NormalC->getType()
->gatherAllSubstitutions(NormalC->getDeclContext()->getParentModule(),
nullptr);
}
// Did we already find this?
auto found = WitnessTableLookupCache.find(NormalC);
if (found != WitnessTableLookupCache.end())