@@ -1978,6 +1978,11 @@ void PrintAST::printSingleDepthOfGenericSignature(
1978
1978
if (dependsOnOpaque (inverse.subject ))
1979
1979
continue ;
1980
1980
1981
+ if (inverse.getKind () == InvertibleProtocolKind::Escapable &&
1982
+ Options.SuppressNonEscapableTypes ) {
1983
+ continue ;
1984
+ }
1985
+
1981
1986
if (isFirstReq) {
1982
1987
if (printRequirements)
1983
1988
Printer << " " << tok::kw_where << " " ;
@@ -3099,6 +3104,16 @@ suppressingFeatureAllowUnsafeAttribute(PrintOptions &options,
3099
3104
options.ExcludeAttrList .resize (originalExcludeAttrCount);
3100
3105
}
3101
3106
3107
+ static void
3108
+ suppressingFeatureNonescapableTypes (PrintOptions &options,
3109
+ llvm::function_ref<void ()> action) {
3110
+ unsigned originalExcludeAttrCount = options.ExcludeAttrList .size ();
3111
+ options.ExcludeAttrList .push_back (DeclAttrKind::Lifetime);
3112
+ llvm::SaveAndRestore<bool > scope (options.SuppressNonEscapableTypes , true );
3113
+ action ();
3114
+ options.ExcludeAttrList .resize (originalExcludeAttrCount);
3115
+ }
3116
+
3102
3117
// / Suppress the printing of a particular feature.
3103
3118
static void suppressingFeature (PrintOptions &options, Feature feature,
3104
3119
llvm::function_ref<void ()> action) {
@@ -4107,10 +4122,12 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
4107
4122
Printer.printDeclResultTypePre (decl, ResultTyLoc);
4108
4123
Printer.callPrintStructurePre (PrintStructureKind::FunctionReturnType);
4109
4124
{
4110
- if (auto *typeRepr = dyn_cast_or_null<LifetimeDependentTypeRepr>(
4111
- decl->getResultTypeRepr ())) {
4112
- for (auto &dep : typeRepr->getLifetimeDependencies ()) {
4113
- Printer << " " << dep.getDependsOnString () << " " ;
4125
+ if (!Options.SuppressNonEscapableTypes ) {
4126
+ if (auto *typeRepr = dyn_cast_or_null<LifetimeDependentTypeRepr>(
4127
+ decl->getResultTypeRepr ())) {
4128
+ for (auto &dep : typeRepr->getLifetimeDependencies ()) {
4129
+ Printer << " " << dep.getDependsOnString () << " " ;
4130
+ }
4114
4131
}
4115
4132
}
4116
4133
}
@@ -4330,15 +4347,17 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
4330
4347
4331
4348
printGenericDeclGenericParams (decl);
4332
4349
printFunctionParameters (decl);
4333
- if (decl->hasLifetimeDependentReturn ()) {
4334
- Printer << " -> " ;
4335
- auto *typeRepr =
4336
- cast<LifetimeDependentTypeRepr>(decl->getResultTypeRepr ());
4337
- for (auto &dep : typeRepr->getLifetimeDependencies ()) {
4338
- Printer << dep.getDependsOnString () << " " ;
4350
+ if (!Options.SuppressNonEscapableTypes ) {
4351
+ if (decl->hasLifetimeDependentReturn ()) {
4352
+ Printer << " -> " ;
4353
+ auto *typeRepr =
4354
+ cast<LifetimeDependentTypeRepr>(decl->getResultTypeRepr ());
4355
+ for (auto &dep : typeRepr->getLifetimeDependencies ()) {
4356
+ Printer << dep.getDependsOnString () << " " ;
4357
+ }
4358
+ // TODO: Handle failable initializers with lifetime dependent returns
4359
+ Printer << " Self" ;
4339
4360
}
4340
- // TODO: Handle failable initializers with lifetime dependent returns
4341
- Printer << " Self" ;
4342
4361
}
4343
4362
});
4344
4363
@@ -7796,7 +7815,28 @@ swift::getInheritedForPrinting(
7796
7815
}
7797
7816
continue ;
7798
7817
}
7818
+
7819
+ // Suppress Escapable and ~Escapable.
7820
+ if (options.SuppressNonEscapableTypes ) {
7821
+ if (auto pct = ty->getAs <ProtocolCompositionType>()) {
7822
+ auto inverses = pct->getInverses ();
7823
+ if (inverses.contains (InvertibleProtocolKind::Escapable)) {
7824
+ inverses.remove (InvertibleProtocolKind::Escapable);
7825
+ ty = ProtocolCompositionType::get (decl->getASTContext (),
7826
+ pct->getMembers (), inverses,
7827
+ pct->hasExplicitAnyObject ());
7828
+ if (ty->isAny ())
7829
+ continue ;
7830
+ }
7831
+ }
7832
+
7833
+ if (auto protoTy = ty->getAs <ProtocolType>())
7834
+ if (protoTy->getDecl ()->isSpecificProtocol (
7835
+ KnownProtocolKind::Escapable))
7836
+ continue ;
7837
+ }
7799
7838
}
7839
+
7800
7840
if (options.SuppressConformanceSuppression &&
7801
7841
inherited.getEntry (i).isSuppressed ()) {
7802
7842
continue ;
0 commit comments