[serialization] Add support for slice types and variadic functions.

This is the first time reaching the case where the module refers to a type
that also appears in the TU and tries to modify it. This shouldn't be a
problem for any of the other types we currently serialize besides
BoundGenericType and ArraySliceType because we either don't try to modify
them after creation or are guaranteed a new type object.

Swift SVN r6060
This commit is contained in:
Jordan Rose
2013-07-08 19:57:04 +00:00
parent 20e85d48a3
commit 03f7c3ef2c
3 changed files with 40 additions and 1 deletions

View File

@@ -1207,6 +1207,11 @@ Type ModuleFile::getType(TypeID TID) {
getType(parentID), genericArgs);
typeOrOffset = boundTy;
// BoundGenericTypes get uniqued in the ASTContext, so it's possible this
// type already has its substitutions. In that case, ignore the module's.
if (boundTy->hasSubstitutions())
break;
SmallVector<Substitution, 8> substitutions;
while (true) {
auto entry = DeclTypeCursor.advance();
@@ -1289,6 +1294,20 @@ Type ModuleFile::getType(TypeID TID) {
break;
}
case decls_block::ARRAY_SLICE_TYPE: {
TypeID baseID, implID;
decls_block::ArraySliceTypeLayout::readRecord(scratch, baseID, implID);
auto sliceTy = ArraySliceType::get(getType(baseID), ctx);
typeOrOffset = sliceTy;
// Slice types are uniqued by the ASTContext, so they may already have
// type information. If so, ignore the information in the module.
if (!sliceTy->hasImplementationType())
sliceTy->setImplementationType(getType(implID));
break;
}
default:
// We don't know how to deserialize this kind of type.
error();