Partially revert “Maintain the DeclContext of a NormalProtocolConformance as the type declaration or extension.”

We now have this information during parsing and throw it away during deserialization. This half-baked state works because all non-generic-extension clients only care about the module context.

Swift SVN r20833
This commit is contained in:
Doug Gregor
2014-07-31 17:30:08 +00:00
parent 182e0b0d24
commit 0184d9719b
3 changed files with 17 additions and 16 deletions

View File

@@ -131,17 +131,23 @@ GenericParamList *ProtocolConformance::getSubstitutedGenericParams() const {
C = cast<SpecializedProtocolConformance>(C)->getGenericConformance();
FoundSpecializedConformance = true;
continue;
case ProtocolConformanceKind::Normal:
case ProtocolConformanceKind::Normal: {
// If we have a normal protocol conformance and we have not seen a
// specialized protocol conformance yet, we know that the normal protocol
// conformance can only contain open types. Bail.
if (!FoundSpecializedConformance)
return nullptr;
// Otherwise, this must be the original conformance containing the
// specialized generic parameters. Attempt to create the param list.
auto normal = cast<NormalProtocolConformance>(C);
if (auto ext = dyn_cast<ExtensionDecl>(normal->getDeclContext()))
return ext->getGenericParams();
return genericParamListForType(C->getType());
}
}
}
}
@@ -160,11 +166,16 @@ GenericParamList *ProtocolConformance::getGenericParams() const {
// currently partial specialization, we know that it can not have any open
// type variables.
return nullptr;
case ProtocolConformanceKind::Normal:
case ProtocolConformanceKind::Normal: {
// If we have a normal protocol conformance, attempt to look up its open
// generic type variables.
auto normal = cast<NormalProtocolConformance>(C);
if (auto ext = dyn_cast<ExtensionDecl>(normal->getDeclContext()))
return ext->getGenericParams();
return genericParamListForType(C->getType());
}
}
}
}