Skip to content

[Serialization] Wire up the generic parameter of a protocol early. #7473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,10 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
declOrOffset = assocType;

assocType->computeType();

assert(!assocType->getDeclaredInterfaceType()->hasError() &&
"erroneous associated type");

Accessibility parentAccess = cast<ProtocolDecl>(DC)->getFormalAccess();
assocType->setAccessibility(std::max(parentAccess,Accessibility::Internal));
if (isImplicit)
Expand Down Expand Up @@ -3031,8 +3035,6 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
getIdentifier(nameID), None);
declOrOffset = proto;

configureGenericEnvironment(proto, genericEnvID);

proto->setRequiresClass(isClassBounded);

if (auto accessLevel = getActualAccessibility(rawAccessLevel)) {
Expand All @@ -3042,6 +3044,10 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
return nullptr;
}

auto genericParams = maybeReadGenericParams(DC);
assert(genericParams && "protocol with no generic parameters?");
proto->setGenericParams(genericParams);

auto protocols = ctx.Allocate<ProtocolDecl *>(numProtocols);
for_each(protocols, rawProtocolAndInheritedIDs.slice(0, numProtocols),
[this](ProtocolDecl *&p, uint64_t rawID) {
Expand All @@ -3051,9 +3057,7 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {

handleInherited(proto, rawProtocolAndInheritedIDs.slice(numProtocols));

auto genericParams = maybeReadGenericParams(DC);
assert(genericParams && "protocol with no generic parameters?");
proto->setGenericParams(genericParams);
configureGenericEnvironment(proto, genericEnvID);

SmallVector<Requirement, 4> requirements;
readGenericRequirements(requirements, DeclTypeCursor);
Expand Down