@@ -2301,13 +2301,23 @@ class swift::DeclDeserializer {
2301
2301
AttrsNext = Attr->getMutableNext ();
2302
2302
};
2303
2303
2304
- void handleInherited (TypeDecl *nominal, ArrayRef<uint64_t > rawInheritedIDs) {
2305
- auto inheritedTypes = ctx.Allocate <TypeLoc>(rawInheritedIDs.size ());
2306
- for_each (inheritedTypes, rawInheritedIDs,
2307
- [this ](TypeLoc &tl, uint64_t rawID) {
2308
- tl = TypeLoc::withoutLoc (MF.getType (rawID));
2309
- });
2310
- nominal->setInherited (inheritedTypes);
2304
+ void handleInherited (llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl,
2305
+ ArrayRef<uint64_t > rawInheritedIDs) {
2306
+ SmallVector<TypeLoc, 2 > inheritedTypes;
2307
+ for (auto rawID : rawInheritedIDs) {
2308
+ auto maybeType = MF.getTypeChecked (rawID);
2309
+ if (!maybeType) {
2310
+ llvm::consumeError (maybeType.takeError ());
2311
+ continue ;
2312
+ }
2313
+ inheritedTypes.push_back (TypeLoc::withoutLoc (MF.getType (rawID)));
2314
+ }
2315
+
2316
+ auto inherited = ctx.AllocateCopy (inheritedTypes);
2317
+ if (auto *typeDecl = decl.dyn_cast <TypeDecl *>())
2318
+ typeDecl->setInherited (inherited);
2319
+ else
2320
+ decl.get <ExtensionDecl *>()->setInherited (inherited);
2311
2321
}
2312
2322
2313
2323
public:
@@ -3507,13 +3517,13 @@ class swift::DeclDeserializer {
3507
3517
GenericEnvironmentID genericEnvID;
3508
3518
TypeID rawTypeID;
3509
3519
uint8_t rawAccessLevel;
3510
- unsigned numConformances, numInheritedTypes ;
3520
+ unsigned numConformances, numInherited ;
3511
3521
ArrayRef<uint64_t > rawInheritedAndDependencyIDs;
3512
3522
3513
3523
decls_block::EnumLayout::readRecord (scratch, nameID, contextID,
3514
3524
isImplicit, isObjC, genericEnvID,
3515
3525
rawTypeID, rawAccessLevel,
3516
- numConformances, numInheritedTypes ,
3526
+ numConformances, numInherited ,
3517
3527
rawInheritedAndDependencyIDs);
3518
3528
3519
3529
auto DC = MF.getDeclContext (contextID);
@@ -3522,7 +3532,7 @@ class swift::DeclDeserializer {
3522
3532
3523
3533
Identifier name = MF.getIdentifier (nameID);
3524
3534
for (TypeID dependencyID :
3525
- rawInheritedAndDependencyIDs.slice (numInheritedTypes )) {
3535
+ rawInheritedAndDependencyIDs.slice (numInherited )) {
3526
3536
auto dependency = MF.getTypeChecked (dependencyID);
3527
3537
if (!dependency) {
3528
3538
return llvm::make_error<TypeError>(
@@ -3557,8 +3567,8 @@ class swift::DeclDeserializer {
3557
3567
3558
3568
theEnum->computeType ();
3559
3569
3560
- handleInherited (theEnum,
3561
- rawInheritedAndDependencyIDs. slice ( 0 , numInheritedTypes) );
3570
+ auto rawInheritedIDs = rawInheritedAndDependencyIDs. slice ( 0 , numInherited);
3571
+ handleInherited (theEnum, rawInheritedIDs );
3562
3572
3563
3573
theEnum->setMemberLoader (&MF, MF.DeclTypeCursor .GetCurrentBitNo ());
3564
3574
skipRecord (MF.DeclTypeCursor , decls_block::MEMBERS);
@@ -3816,12 +3826,8 @@ class swift::DeclDeserializer {
3816
3826
if (isImplicit)
3817
3827
extension->setImplicit ();
3818
3828
3819
- auto inheritedTypes = ctx.Allocate <TypeLoc>(numInherited);
3820
- for_each (inheritedTypes, inheritedAndDependencyIDs.slice (0 , numInherited),
3821
- [this ](TypeLoc &tl, uint64_t rawID) {
3822
- tl = TypeLoc::withoutLoc (MF.getType (rawID));
3823
- });
3824
- extension->setInherited (inheritedTypes);
3829
+ auto rawInheritedIDs = inheritedAndDependencyIDs.slice (0 , numInherited);
3830
+ handleInherited (extension, rawInheritedIDs);
3825
3831
3826
3832
extension->setMemberLoader (&MF, MF.DeclTypeCursor .GetCurrentBitNo ());
3827
3833
skipRecord (MF.DeclTypeCursor , decls_block::MEMBERS);
0 commit comments