@@ -2525,13 +2525,20 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
2525
2525
Optional<swift::CtorInitializerKind> initKind =
2526
2526
getActualCtorInitializerKind (storedInitKind);
2527
2527
2528
+ auto errorKind = DeclDeserializationError::Normal;
2529
+ if (initKind == CtorInitializerKind::Designated)
2530
+ errorKind = DeclDeserializationError::DesignatedInitializer;
2531
+
2528
2532
auto overridden = getDeclChecked (overriddenID);
2529
2533
if (!overridden) {
2530
2534
llvm::consumeError (overridden.takeError ());
2531
- auto kind = OverrideError::Normal;
2532
- if (initKind == CtorInitializerKind::Designated)
2533
- kind = OverrideError::DesignatedInitializer;
2534
- return llvm::make_error<OverrideError>(name, kind);
2535
+ return llvm::make_error<OverrideError>(name, errorKind);
2536
+ }
2537
+
2538
+ auto canonicalType = getTypeChecked (canonicalTypeID);
2539
+ if (!canonicalType) {
2540
+ return llvm::make_error<TypeError>(
2541
+ name, takeErrorInfo (canonicalType.takeError ()), errorKind);
2535
2542
}
2536
2543
2537
2544
auto parent = getDeclContext (contextID);
@@ -2629,8 +2636,10 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
2629
2636
}
2630
2637
2631
2638
auto canonicalType = getTypeChecked (canonicalTypeID);
2632
- if (!canonicalType)
2633
- return llvm::make_error<TypeError>(name, takeErrorInfo (canonicalType.takeError ()));
2639
+ if (!canonicalType) {
2640
+ return llvm::make_error<TypeError>(
2641
+ name, takeErrorInfo (canonicalType.takeError ()));
2642
+ }
2634
2643
2635
2644
auto DC = ForcedContext ? *ForcedContext : getDeclContext (contextID);
2636
2645
if (declOrOffset.isComplete ())
@@ -2757,13 +2766,21 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
2757
2766
}
2758
2767
2759
2768
auto canonicalType = getTypeChecked (canonicalTypeID);
2760
- if (!canonicalType)
2761
- return llvm::make_error<TypeError>(name, takeErrorInfo (canonicalType.takeError ()));
2769
+ if (!canonicalType) {
2770
+ return llvm::make_error<TypeError>(
2771
+ name, takeErrorInfo (canonicalType.takeError ()));
2772
+ }
2762
2773
2763
2774
auto DC = getDeclContext (contextID);
2764
2775
if (declOrOffset.isComplete ())
2765
2776
return declOrOffset;
2766
2777
2778
+ // If we are an accessor on a var or subscript, make sure it is deserialized
2779
+ // first.
2780
+ auto accessor = getDeclChecked (accessorStorageDeclID);
2781
+ if (!accessor)
2782
+ return accessor.takeError ();
2783
+
2767
2784
// Read generic params before reading the type, because the type may
2768
2785
// reference generic parameters, and we want them to have a dummy
2769
2786
// DeclContext for now.
@@ -2844,10 +2861,6 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
2844
2861
fn->setImplicit ();
2845
2862
fn->setMutating (isMutating);
2846
2863
fn->setDynamicSelf (hasDynamicSelf);
2847
-
2848
- // If we are an accessor on a var or subscript, make sure it is deserialized
2849
- // too.
2850
- getDecl (accessorStorageDeclID);
2851
2864
break ;
2852
2865
}
2853
2866
@@ -3289,6 +3302,12 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
3289
3302
return llvm::make_error<OverrideError>(name);
3290
3303
}
3291
3304
3305
+ auto canonicalType = getTypeChecked (canonicalTypeID);
3306
+ if (!canonicalType) {
3307
+ return llvm::make_error<TypeError>(
3308
+ name, takeErrorInfo (canonicalType.takeError ()));
3309
+ }
3310
+
3292
3311
auto parent = getDeclContext (contextID);
3293
3312
if (declOrOffset.isComplete ())
3294
3313
return declOrOffset;
@@ -4342,6 +4361,9 @@ void ModuleFile::loadAllMembers(Decl *container, uint64_t contextData) {
4342
4361
fatal (next.takeError ());
4343
4362
4344
4363
// Drop the member if it had a problem.
4364
+ // FIXME: If this was a non-final, non-dynamic, non-@objc-overriding
4365
+ // member, it's going to affect the vtable layout, and /every single call/
4366
+ // will be wrong.
4345
4367
if (auto *containingClass = dyn_cast<ClassDecl>(container)) {
4346
4368
auto handleMissingDesignatedInit =
4347
4369
[containingClass](const DeclDeserializationError &error) {
0 commit comments