[AST] NFC: Refactor GenericTypeParamDecl construction

Add distinct overloads for the parser,
deserialization and code synthesis.
This commit is contained in:
Hamish Knight
2022-10-14 15:40:12 +01:00
parent 1c9b77ef54
commit b645e63ce5
13 changed files with 176 additions and 94 deletions

View File

@@ -1162,9 +1162,10 @@ ModuleFile::getGenericSignatureChecked(serialization::GenericSignatureID ID) {
auto paramTy = getType(rawParamIDs[i+1])->castTo<GenericTypeParamType>();
if (!name.empty()) {
auto paramDecl = GenericTypeParamDecl::create(
getAssociatedModule(), name, SourceLoc(), paramTy->isParameterPack(),
paramTy->getDepth(), paramTy->getIndex(), false, nullptr);
auto *paramDecl = GenericTypeParamDecl::createDeserialized(
getAssociatedModule(), name, paramTy->getDepth(),
paramTy->getIndex(), paramTy->isParameterPack(),
/*isOpaqueType*/ false);
paramTy = paramDecl->getDeclaredInterfaceType()
->castTo<GenericTypeParamType>();
}
@@ -2835,9 +2836,9 @@ public:
// Always create GenericTypeParamDecls in the associated file; the real
// context will reparent them.
auto *DC = MF.getFile();
auto genericParam = GenericTypeParamDecl::create(
DC, MF.getIdentifier(nameID), SourceLoc(), isParameterPack, depth,
index, isOpaqueType, /*opaqueTypeRepr=*/nullptr);
auto *genericParam = GenericTypeParamDecl::createDeserialized(
DC, MF.getIdentifier(nameID), depth, index, isParameterPack,
isOpaqueType);
declOrOffset = genericParam;
if (isImplicit)