@@ -2579,6 +2579,9 @@ void PrintAST::printInherited(const Decl *decl) {
25792579 interleave (TypesToPrint, [&](InheritedEntry inherited) {
25802580 if (inherited.isUnchecked )
25812581 Printer << " @unchecked " ;
2582+ if (inherited.isRetroactive &&
2583+ !llvm::is_contained (Options.ExcludeAttrList , TAK_retroactive))
2584+ Printer << " @retroactive " ;
25822585
25832586 printTypeLoc (inherited);
25842587 }, [&]() {
@@ -3049,6 +3052,18 @@ static bool usesFeatureGlobalActors(Decl *decl) {
30493052 return false ;
30503053}
30513054
3055+ static bool usesFeatureRetroactiveAttribute (Decl *decl) {
3056+ auto ext = dyn_cast<ExtensionDecl>(decl);
3057+ if (!ext)
3058+ return false ;
3059+
3060+ ArrayRef<InheritedEntry> entries = ext->getInherited ().getEntries ();
3061+ return std::find_if (entries.begin (), entries.end (),
3062+ [](const InheritedEntry &entry) {
3063+ return entry.isRetroactive ;
3064+ }) != entries.end ();
3065+ }
3066+
30523067static bool usesBuiltinType (Decl *decl, BuiltinTypeKind kind) {
30533068 auto typeMatches = [kind](Type type) {
30543069 return type.findIf ([&](Type type) {
@@ -3477,6 +3492,14 @@ suppressingFeatureNoAsyncAvailability(PrintOptions &options,
34773492 action ();
34783493}
34793494
3495+ static void suppressingFeatureRetroactiveAttribute (
3496+ PrintOptions &options,
3497+ llvm::function_ref<void ()> action) {
3498+ llvm::SaveAndRestore<PrintOptions> originalOptions (options);
3499+ options.ExcludeAttrList .push_back (TAK_retroactive);
3500+ action ();
3501+ }
3502+
34803503static bool usesFeatureReferenceBindings (Decl *decl) {
34813504 auto *vd = dyn_cast<VarDecl>(decl);
34823505 return vd && vd->getIntroducer () == VarDecl::Introducer::InOut;
@@ -7894,7 +7917,8 @@ swift::getInheritedForPrinting(
78947917 }
78957918
78967919 Results.push_back ({TypeLoc::withoutLoc (proto->getDeclaredInterfaceType ()),
7897- isUnchecked});
7920+ isUnchecked,
7921+ /* isRetroactive=*/ false });
78987922 }
78997923}
79007924
0 commit comments