@@ -2727,7 +2727,19 @@ class swift::DeclDeserializer {
2727
2727
2728
2728
// If there are any backing properties, record them.
2729
2729
if (numBackingProperties > 0 ) {
2730
- VarDecl *backingVar = cast<VarDecl>(MF.getDecl (backingPropertyIDs[0 ]));
2730
+ auto backingDecl = MF.getDeclChecked (backingPropertyIDs[0 ]);
2731
+ if (!backingDecl) {
2732
+ if (numBackingProperties > 1 &&
2733
+ backingDecl.errorIsA <XRefNonLoadedModuleError>()) {
2734
+ // A property wrapper defined behind an implementation-only import
2735
+ // is safe to drop when it can't be deserialized.
2736
+ // rdar://problem/56599179
2737
+ consumeError (backingDecl.takeError ());
2738
+ } else
2739
+ return backingDecl.takeError ();
2740
+ }
2741
+
2742
+ VarDecl *backingVar = cast<VarDecl>(backingDecl.get ());
2731
2743
VarDecl *storageWrapperVar = nullptr ;
2732
2744
if (numBackingProperties > 1 ) {
2733
2745
storageWrapperVar = cast<VarDecl>(MF.getDecl (backingPropertyIDs[1 ]));
@@ -3873,6 +3885,7 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
3873
3885
3874
3886
if (isDeclAttrRecord (recordID)) {
3875
3887
DeclAttribute *Attr = nullptr ;
3888
+ bool skipAttr = false ;
3876
3889
switch (recordID) {
3877
3890
case decls_block::SILGenName_DECL_ATTR: {
3878
3891
bool isImplicit;
@@ -4073,13 +4086,19 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
4073
4086
4074
4087
Expected<Type> deserialized = MF.getTypeChecked (typeID);
4075
4088
if (!deserialized) {
4076
- MF.fatal (deserialized.takeError ());
4077
- break ;
4089
+ if (deserialized.errorIsA <XRefNonLoadedModuleError>()) {
4090
+ // A custom attribute defined behind an implementation-only import
4091
+ // is safe to drop when it can't be deserialized.
4092
+ // rdar://problem/56599179
4093
+ consumeError (deserialized.takeError ());
4094
+ skipAttr = true ;
4095
+ } else
4096
+ return deserialized.takeError ();
4097
+ } else {
4098
+ Attr = CustomAttr::create (ctx, SourceLoc (),
4099
+ TypeLoc::withoutLoc (deserialized.get ()),
4100
+ isImplicit);
4078
4101
}
4079
-
4080
- Attr = CustomAttr::create (ctx, SourceLoc (),
4081
- TypeLoc::withoutLoc (deserialized.get ()),
4082
- isImplicit);
4083
4102
break ;
4084
4103
}
4085
4104
@@ -4110,10 +4129,12 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
4110
4129
MF.fatal ();
4111
4130
}
4112
4131
4113
- if (!Attr)
4114
- return llvm::Error::success ();
4132
+ if (!skipAttr) {
4133
+ if (!Attr)
4134
+ return llvm::Error::success ();
4115
4135
4116
- AddAttribute (Attr);
4136
+ AddAttribute (Attr);
4137
+ }
4117
4138
4118
4139
} else if (recordID == decls_block::PRIVATE_DISCRIMINATOR) {
4119
4140
IdentifierID discriminatorID;
0 commit comments