@@ -2535,11 +2535,7 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
25352535}
25362536
25372537void PrintAST::visitParamDecl (ParamDecl *decl) {
2538- // Set and restore in-parameter-position printing of types
2539- auto prior = Options.PrintAsInParamType ;
2540- Options.PrintAsInParamType = true ;
2541- visitVarDecl (decl);
2542- Options.PrintAsInParamType = prior;
2538+ return visitVarDecl (decl);
25432539}
25442540
25452541void PrintAST::printOneParameter (const ParamDecl *param, bool Curried,
@@ -2593,11 +2589,7 @@ void PrintAST::printOneParameter(const ParamDecl *param, bool Curried,
25932589 TheTypeLoc.setType (BGT->getGenericArgs ()[0 ]);
25942590 }
25952591
2596- // Set and restore in-parameter-position printing of types
2597- auto prior = Options.PrintAsInParamType ;
2598- Options.PrintAsInParamType = true ;
25992592 printTypeLoc (TheTypeLoc);
2600- Options.PrintAsInParamType = prior;
26012593
26022594 if (param->isVariadic ())
26032595 Printer << " ..." ;
@@ -3321,10 +3313,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
33213313 const PrintOptions &Options;
33223314 Optional<std::vector<GenericParamList *>> UnwrappedGenericParams;
33233315
3324- // / Whether we are printing something in a function parameter position, and
3325- // / thus want to print @escaping if it escapes.
3326- bool inParameterPrinting;
3327-
33283316 void printDeclContext (DeclContext *DC) {
33293317 switch (DC->getContextKind ()) {
33303318 case DeclContextKind::Module: {
@@ -3492,8 +3480,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
34923480
34933481public:
34943482 TypePrinter (ASTPrinter &Printer, const PrintOptions &PO)
3495- : Printer(Printer), Options(PO),
3496- inParameterPrinting (Options.PrintAsInParamType) {}
3483+ : Printer(Printer), Options(PO) {}
34973484
34983485 void visit (Type T) {
34993486 Printer.printTypePre (TypeLoc::withoutLoc (T));
@@ -3758,10 +3745,11 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
37583745 Printer << " @autoclosure " ;
37593746 else
37603747 Printer << " @autoclosure(escaping) " ;
3761- } else if (inParameterPrinting) {
3762- if (!info.isNoEscape ()) {
3763- Printer << " @escaping " ;
3764- }
3748+ } else if (info.isNoEscape ()) {
3749+ // autoclosure implies noescape.
3750+ Printer << " @noescape " ;
3751+ } else if (info.isExplicitlyEscaping ()) {
3752+ Printer << " @escaping " ;
37653753 }
37663754
37673755 if (Options.PrintFunctionRepresentationAttrs ) {
@@ -3853,17 +3841,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
38533841
38543842 if (needsParens)
38553843 Printer << " (" ;
3856-
3857- // Set in-parameter-position printing to print our parameters, then unset it
3858- // for the return type (in case it is also a function), and restore at the
3859- // end.
3860- auto prior = inParameterPrinting;
3861- inParameterPrinting = true ;
3844+
38623845 visit (inputType);
3863- inParameterPrinting = false ;
3864- SWIFT_DEFER {
3865- inParameterPrinting = prior;
3866- };
38673846
38683847 if (needsParens)
38693848 Printer << " )" ;
0 commit comments