@@ -983,12 +983,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
983
983
// / The default generic signature flags for printing requirements.
984
984
static unsigned
985
985
defaultGenericRequirementFlags (const PrintOptions &options) {
986
- unsigned flags = PrintRequirements;
987
-
988
- if (!options.SuppressNoncopyableGenerics )
989
- flags |= PrintInverseRequirements;
990
-
991
- return flags;
986
+ return PrintRequirements | PrintInverseRequirements;
992
987
}
993
988
994
989
void printInheritedFromRequirementSignature (ProtocolDecl *proto,
@@ -1148,18 +1143,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
1148
1143
Printer.callPrintDeclPre (D, Options.BracketOptions );
1149
1144
1150
1145
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); });
1163
1148
} else {
1164
1149
ASTVisitor::visit (D);
1165
1150
}
@@ -1642,9 +1627,8 @@ void PrintAST::printInheritedFromRequirementSignature(ProtocolDecl *proto,
1642
1627
// The invertible protocols themselves do not need to state inverses in their
1643
1628
// inheritance clause, because they do not gain any default requirements.
1644
1629
// 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))
1648
1632
flags |= PrintInverseRequirements;
1649
1633
1650
1634
printRequirementSignature (
@@ -1701,18 +1685,6 @@ void PrintAST::printGenericSignature(GenericSignature genericSig,
1701
1685
AllInverses ());
1702
1686
}
1703
1687
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
-
1716
1688
InversesAtDepth::InversesAtDepth (GenericContext *level) {
1717
1689
includedDepth = std::nullopt;
1718
1690
// Does this generic context have its own generic parameters?
@@ -1745,9 +1717,6 @@ void PrintAST::printGenericSignature(
1745
1717
} else {
1746
1718
requirements.append (genericSig.getRequirements ().begin (),
1747
1719
genericSig.getRequirements ().end ());
1748
-
1749
- if (Options.SuppressNoncopyableGenerics )
1750
- eraseInvertibleProtocolConformances (requirements);
1751
1720
}
1752
1721
1753
1722
if (flags & InnermostOnly) {
@@ -2026,9 +1995,6 @@ void PrintAST::printRequirementSignature(ProtocolDecl *owner,
2026
1995
} else {
2027
1996
requirements.append (sig.getRequirements ().begin (),
2028
1997
sig.getRequirements ().end ());
2029
-
2030
- if (Options.SuppressNoncopyableGenerics )
2031
- eraseInvertibleProtocolConformances (requirements);
2032
1998
}
2033
1999
2034
2000
if (attachingTo) {
@@ -3172,17 +3138,6 @@ static void suppressingFeatureAssociatedTypeImplements(PrintOptions &options,
3172
3138
options.ExcludeAttrList .resize (originalExcludeAttrCount);
3173
3139
}
3174
3140
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
-
3186
3141
static void
3187
3142
suppressingFeatureConformanceSuppression (PrintOptions &options,
3188
3143
llvm::function_ref<void ()> action) {
@@ -3783,14 +3738,10 @@ static void printParameterFlags(ASTPrinter &printer,
3783
3738
printer.printKeyword (" inout" , options, " " );
3784
3739
break ;
3785
3740
case ParamSpecifier::Borrowing:
3786
- if (!options.SuppressNoncopyableOwnershipModifiers ) {
3787
- printer.printKeyword (" borrowing" , options, " " );
3788
- }
3741
+ printer.printKeyword (" borrowing" , options, " " );
3789
3742
break ;
3790
3743
case ParamSpecifier::Consuming:
3791
- if (!options.SuppressNoncopyableOwnershipModifiers ) {
3792
- printer.printKeyword (" consuming" , options, " " );
3793
- }
3744
+ printer.printKeyword (" consuming" , options, " " );
3794
3745
break ;
3795
3746
case ParamSpecifier::LegacyShared:
3796
3747
printer.printKeyword (" __shared" , options, " " );
@@ -7481,7 +7432,7 @@ void GenericSignature::print(ASTPrinter &Printer,
7481
7432
}
7482
7433
7483
7434
auto flags = PrintAST::PrintParams | PrintAST::PrintRequirements;
7484
- if (Opts.PrintInverseRequirements && !Opts. SuppressNoncopyableGenerics )
7435
+ if (Opts.PrintInverseRequirements )
7485
7436
flags |= PrintAST::PrintInverseRequirements;
7486
7437
PrintAST (Printer, Opts).printGenericSignature (*this , flags);
7487
7438
}
@@ -7497,7 +7448,7 @@ void RequirementSignature::print(ProtocolDecl *owner,
7497
7448
ASTPrinter &Printer,
7498
7449
const PrintOptions &Opts) const {
7499
7450
auto flags = PrintAST::PrintParams | PrintAST::PrintRequirements;
7500
- if (Opts.PrintInverseRequirements && !Opts. SuppressNoncopyableGenerics )
7451
+ if (Opts.PrintInverseRequirements )
7501
7452
flags |= PrintAST::PrintInverseRequirements;
7502
7453
PrintAST (Printer, Opts).printRequirementSignature (owner, *this , flags, nullptr );
7503
7454
}
@@ -7898,10 +7849,6 @@ swift::getInheritedForPrinting(
7898
7849
7899
7850
// Preserve any inverses that appeared in the unprintable type.
7900
7851
if (foundUnprintable) {
7901
- if (printableInverses.contains (InvertibleProtocolKind::Copyable)
7902
- && options.SuppressNoncopyableGenerics )
7903
- printableInverses.remove (InvertibleProtocolKind::Copyable);
7904
-
7905
7852
if (!printableInverses.empty ()) {
7906
7853
auto inversesTy = ProtocolCompositionType::get (decl->getASTContext (),
7907
7854
/* members=*/ {},
@@ -7911,26 +7858,6 @@ swift::getInheritedForPrinting(
7911
7858
}
7912
7859
continue ;
7913
7860
}
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
- }
7934
7861
}
7935
7862
if (options.SuppressConformanceSuppression &&
7936
7863
inherited.getEntry (i).isSuppressed ()) {
0 commit comments