@@ -983,12 +983,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
983983 // / The default generic signature flags for printing requirements.
984984 static unsigned
985985 defaultGenericRequirementFlags (const PrintOptions &options) {
986- unsigned flags = PrintRequirements;
987-
988- if (!options.SuppressNoncopyableGenerics )
989- flags |= PrintInverseRequirements;
990-
991- return flags;
986+ return PrintRequirements | PrintInverseRequirements;
992987 }
993988
994989 void printInheritedFromRequirementSignature (ProtocolDecl *proto,
@@ -1148,18 +1143,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
11481143 Printer.callPrintDeclPre (D, Options.BracketOptions );
11491144
11501145 if (Options.PrintCompatibilityFeatureChecks ) {
1151- printWithCompatibilityFeatureChecks (Printer, Options, D, [&] {
1152- // If we are in a scope where non-copyable generics are being suppressed
1153- // and we are also printing a decl that has @_preInverseGenerics, make
1154- // sure we also suppress printing ownership modifiers that were added
1155- // to satisfy the requirements of non-copyability.
1156- llvm::SaveAndRestore<bool > scope (
1157- Options.SuppressNoncopyableOwnershipModifiers ,
1158- Options.SuppressNoncopyableGenerics &&
1159- D->getAttrs ().hasAttribute <PreInverseGenericsAttr>());
1160-
1161- ASTVisitor::visit (D);
1162- });
1146+ printWithCompatibilityFeatureChecks (Printer, Options, D,
1147+ [&] { ASTVisitor::visit (D); });
11631148 } else {
11641149 ASTVisitor::visit (D);
11651150 }
@@ -1642,9 +1627,8 @@ void PrintAST::printInheritedFromRequirementSignature(ProtocolDecl *proto,
16421627 // The invertible protocols themselves do not need to state inverses in their
16431628 // inheritance clause, because they do not gain any default requirements.
16441629 // HACK: also exclude Sendable from getting inverses printed.
1645- if (!proto->getInvertibleProtocolKind ()
1646- && !proto->isSpecificProtocol (KnownProtocolKind::Sendable) &&
1647- !Options.SuppressNoncopyableGenerics )
1630+ if (!proto->getInvertibleProtocolKind () &&
1631+ !proto->isSpecificProtocol (KnownProtocolKind::Sendable))
16481632 flags |= PrintInverseRequirements;
16491633
16501634 printRequirementSignature (
@@ -1701,18 +1685,6 @@ void PrintAST::printGenericSignature(GenericSignature genericSig,
17011685 AllInverses ());
17021686}
17031687
1704- // Erase any requirements involving invertible protocols.
1705- static void eraseInvertibleProtocolConformances (
1706- SmallVectorImpl<Requirement> &requirements) {
1707- llvm::erase_if (requirements, [&](Requirement req) {
1708- if (req.getKind () != RequirementKind::Conformance)
1709- return false ;
1710-
1711- return req.getProtocolDecl ()
1712- ->getInvertibleProtocolKind ().has_value ();
1713- });
1714- }
1715-
17161688InversesAtDepth::InversesAtDepth (GenericContext *level) {
17171689 includedDepth = std::nullopt ;
17181690 // Does this generic context have its own generic parameters?
@@ -1745,9 +1717,6 @@ void PrintAST::printGenericSignature(
17451717 } else {
17461718 requirements.append (genericSig.getRequirements ().begin (),
17471719 genericSig.getRequirements ().end ());
1748-
1749- if (Options.SuppressNoncopyableGenerics )
1750- eraseInvertibleProtocolConformances (requirements);
17511720 }
17521721
17531722 if (flags & InnermostOnly) {
@@ -2026,9 +1995,6 @@ void PrintAST::printRequirementSignature(ProtocolDecl *owner,
20261995 } else {
20271996 requirements.append (sig.getRequirements ().begin (),
20281997 sig.getRequirements ().end ());
2029-
2030- if (Options.SuppressNoncopyableGenerics )
2031- eraseInvertibleProtocolConformances (requirements);
20321998 }
20331999
20342000 if (attachingTo) {
@@ -3172,17 +3138,6 @@ static void suppressingFeatureAssociatedTypeImplements(PrintOptions &options,
31723138 options.ExcludeAttrList .resize (originalExcludeAttrCount);
31733139}
31743140
3175- static void suppressingFeatureNoncopyableGenerics (
3176- PrintOptions &options,
3177- llvm::function_ref<void ()> action) {
3178- unsigned originalExcludeAttrCount = options.ExcludeAttrList .size ();
3179- options.ExcludeAttrList .push_back (DeclAttrKind::PreInverseGenerics);
3180- llvm::SaveAndRestore<bool > scope (
3181- options.SuppressNoncopyableGenerics , true );
3182- action ();
3183- options.ExcludeAttrList .resize (originalExcludeAttrCount);
3184- }
3185-
31863141static void
31873142suppressingFeatureConformanceSuppression (PrintOptions &options,
31883143 llvm::function_ref<void ()> action) {
@@ -3783,14 +3738,10 @@ static void printParameterFlags(ASTPrinter &printer,
37833738 printer.printKeyword (" inout" , options, " " );
37843739 break ;
37853740 case ParamSpecifier::Borrowing:
3786- if (!options.SuppressNoncopyableOwnershipModifiers ) {
3787- printer.printKeyword (" borrowing" , options, " " );
3788- }
3741+ printer.printKeyword (" borrowing" , options, " " );
37893742 break ;
37903743 case ParamSpecifier::Consuming:
3791- if (!options.SuppressNoncopyableOwnershipModifiers ) {
3792- printer.printKeyword (" consuming" , options, " " );
3793- }
3744+ printer.printKeyword (" consuming" , options, " " );
37943745 break ;
37953746 case ParamSpecifier::LegacyShared:
37963747 printer.printKeyword (" __shared" , options, " " );
@@ -7481,7 +7432,7 @@ void GenericSignature::print(ASTPrinter &Printer,
74817432 }
74827433
74837434 auto flags = PrintAST::PrintParams | PrintAST::PrintRequirements;
7484- if (Opts.PrintInverseRequirements && !Opts. SuppressNoncopyableGenerics )
7435+ if (Opts.PrintInverseRequirements )
74857436 flags |= PrintAST::PrintInverseRequirements;
74867437 PrintAST (Printer, Opts).printGenericSignature (*this , flags);
74877438}
@@ -7497,7 +7448,7 @@ void RequirementSignature::print(ProtocolDecl *owner,
74977448 ASTPrinter &Printer,
74987449 const PrintOptions &Opts) const {
74997450 auto flags = PrintAST::PrintParams | PrintAST::PrintRequirements;
7500- if (Opts.PrintInverseRequirements && !Opts. SuppressNoncopyableGenerics )
7451+ if (Opts.PrintInverseRequirements )
75017452 flags |= PrintAST::PrintInverseRequirements;
75027453 PrintAST (Printer, Opts).printRequirementSignature (owner, *this , flags, nullptr );
75037454}
@@ -7898,10 +7849,6 @@ swift::getInheritedForPrinting(
78987849
78997850 // Preserve any inverses that appeared in the unprintable type.
79007851 if (foundUnprintable) {
7901- if (printableInverses.contains (InvertibleProtocolKind::Copyable)
7902- && options.SuppressNoncopyableGenerics )
7903- printableInverses.remove (InvertibleProtocolKind::Copyable);
7904-
79057852 if (!printableInverses.empty ()) {
79067853 auto inversesTy = ProtocolCompositionType::get (decl->getASTContext (),
79077854 /* members=*/ {},
@@ -7911,26 +7858,6 @@ swift::getInheritedForPrinting(
79117858 }
79127859 continue ;
79137860 }
7914-
7915- // Suppress Copyable and ~Copyable.
7916- if (options.SuppressNoncopyableGenerics ) {
7917- if (auto pct = ty->getAs <ProtocolCompositionType>()) {
7918- auto inverses = pct->getInverses ();
7919- if (inverses.contains (InvertibleProtocolKind::Copyable)) {
7920- inverses.remove (InvertibleProtocolKind::Copyable);
7921- ty = ProtocolCompositionType::get (decl->getASTContext (),
7922- pct->getMembers (),
7923- inverses,
7924- pct->hasExplicitAnyObject ());
7925- if (ty->isAny ())
7926- continue ;
7927- }
7928- }
7929-
7930- if (auto protoTy = ty->getAs <ProtocolType>())
7931- if (protoTy->getDecl ()->isSpecificProtocol (KnownProtocolKind::Copyable))
7932- continue ;
7933- }
79347861 }
79357862 if (options.SuppressConformanceSuppression &&
79367863 inherited.getEntry (i).isSuppressed ()) {
0 commit comments