@@ -2762,6 +2762,17 @@ ModuleDecl *ModuleFile::getModule(ImportPath::Module name,
2762
2762
return getContext ().getLoadedModule (name);
2763
2763
}
2764
2764
2765
+ static void filterUnsupportedPlatformKinds (SmallVectorImpl<AvailableAttr *> &availabilityAttrs) {
2766
+ auto it = availabilityAttrs.begin ();
2767
+ while (it != availabilityAttrs.end ()) {
2768
+ unsigned platform = (unsigned )(*it)->Platform ;
2769
+ if (platform >= /* PlatformKind::visionOS*/ 13 ) {
2770
+ it = availabilityAttrs.erase (it);
2771
+ } else {
2772
+ ++it;
2773
+ }
2774
+ }
2775
+ }
2765
2776
2766
2777
// / Translate from the Serialization associativity enum values to the AST
2767
2778
// / strongly-typed enum.
@@ -5280,6 +5291,11 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
5280
5291
isPackageDescriptionVersionSpecific, isSPI, LIST_VER_TUPLE_PIECES (Introduced),
5281
5292
LIST_VER_TUPLE_PIECES (Deprecated), LIST_VER_TUPLE_PIECES (Obsoleted),
5282
5293
platform, renameDeclID, messageSize, renameSize);
5294
+
5295
+ // Hack: Filter the un-supported platforms from swiftmodule
5296
+ if (platform >= /* PlatformKind::visionOS*/ 13 ) {
5297
+ return nullptr ;
5298
+ }
5283
5299
5284
5300
ValueDecl *renameDecl = nullptr ;
5285
5301
if (renameDeclID) {
@@ -5513,6 +5529,7 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {
5513
5529
5514
5530
case decls_block::Available_DECL_ATTR: {
5515
5531
Attr = readAvailable_DECL_ATTR (scratch, blobData);
5532
+ if (!Attr) skipAttr = true ;
5516
5533
break ;
5517
5534
}
5518
5535
@@ -5629,6 +5646,15 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {
5629
5646
restoreOffset2.cancel ();
5630
5647
--numAvailabilityAttrs;
5631
5648
}
5649
+
5650
+ // Hack: When deserialized from some un-supported @available attr decl, we should remove it
5651
+ // @available (iOS, macOS, visionOS) -> @available (iOS, macOS)
5652
+ filterUnsupportedPlatformKinds (availabilityAttrs);
5653
+ if (availabilityAttrs.empty ()) {
5654
+ // If attr list is empty, then remove this attr
5655
+ skipAttr = true ;
5656
+ break ;
5657
+ }
5632
5658
5633
5659
auto specializedSig = MF.getGenericSignature (specializedSigID);
5634
5660
Attr = SpecializeAttr::create (ctx, exported != 0 , specializationKind,
0 commit comments