@@ -873,7 +873,11 @@ ProtocolConformanceDeserializer::readInheritedProtocolConformance(
873
873
InheritedProtocolConformanceLayout::readRecord (scratch, conformanceID,
874
874
conformingTypeID);
875
875
876
- Type conformingType = MF.getType (conformingTypeID);
876
+ auto conformingTypeOrError =
877
+ MF.getTypeChecked (conformingTypeID);
878
+ if (!conformingTypeOrError)
879
+ return conformingTypeOrError.takeError ();
880
+ Type conformingType = conformingTypeOrError.get ();
877
881
878
882
PrettyStackTraceType trace (ctx, " reading inherited conformance for" ,
879
883
conformingType);
@@ -3465,7 +3469,10 @@ class DeclDeserializer {
3465
3469
}
3466
3470
}
3467
3471
3468
- auto DC = MF.getDeclContext (contextID);
3472
+ auto DCOrError = MF.getDeclContextChecked (contextID);
3473
+ if (!DCOrError)
3474
+ return DCOrError.takeError ();
3475
+ auto DC = DCOrError.get ();
3469
3476
if (declOrOffset.isComplete ())
3470
3477
return declOrOffset;
3471
3478
@@ -3806,14 +3813,22 @@ class DeclDeserializer {
3806
3813
AddAttribute (new (ctx) HasStorageAttr (/* isImplicit:*/ true ));
3807
3814
3808
3815
if (opaqueReturnTypeID) {
3816
+ auto opaqueReturnType = MF.getDeclChecked (opaqueReturnTypeID);
3817
+ if (!opaqueReturnType)
3818
+ return opaqueReturnType.takeError ();
3819
+
3809
3820
ctx.evaluator .cacheOutput (
3810
3821
OpaqueResultTypeRequest{var},
3811
- cast<OpaqueTypeDecl>(MF. getDecl (opaqueReturnTypeID )));
3822
+ cast<OpaqueTypeDecl>(opaqueReturnType. get ( )));
3812
3823
}
3813
3824
3814
3825
// If this is a lazy property, record its backing storage.
3815
3826
if (lazyStorageID) {
3816
- VarDecl *storage = cast<VarDecl>(MF.getDecl (lazyStorageID));
3827
+ auto lazyStorageDecl = MF.getDeclChecked (lazyStorageID);
3828
+ if (!lazyStorageDecl)
3829
+ return lazyStorageDecl.takeError ();
3830
+
3831
+ VarDecl *storage = cast<VarDecl>(lazyStorageDecl.get ());
3817
3832
ctx.evaluator .cacheOutput (
3818
3833
LazyStoragePropertyRequest{var}, std::move (storage));
3819
3834
}
0 commit comments