Force generic parameter types declared in module context to belong to

the current SIL module, unless the AST sees them first.

This turns out to be important when we deserialize generic
reabstraction thunks, which have shared linkage so get serialized
again in the current SIL module.

There are some fundamental inconsistencies in the way parameter type
decls are handled, but we need a quick workaround to unblock progress
on the stdlib.

Fixes
<rdar://problem/16807985> Building Foundation overlay crashes in stdlib deserialization in r17377

Swift SVN r18173
This commit is contained in:
Andrew Trick
2014-05-16 04:27:09 +00:00
parent c1db20d178
commit fa898f5562
3 changed files with 23 additions and 2 deletions

View File

@@ -1136,6 +1136,8 @@ void Serializer::writeCrossReference(const Decl *D) {
writeCrossReference(D->getDeclContext());
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(D)) {
assert(!D->getDeclContext()->isModuleScopeContext() &&
"Cannot cross reference a generic type decl at module scope.");
abbrCode = DeclTypeAbbrCodes[XRefGenericParamPathPieceLayout::Code];
XRefGenericParamPathPieceLayout::emitRecord(Out, ScratchRecord, abbrCode,
genericParam->getIndex());