@@ -229,6 +229,8 @@ static NonRecursivePrintOptions getNonRecursiveOptions(const ValueDecl *D) {
229229 NonRecursivePrintOptions options;
230230 if (D->isImplicitlyUnwrappedOptional ())
231231 options |= NonRecursivePrintOption::ImplicitlyUnwrappedOptional;
232+ if (isa<ParamDecl>(D))
233+ options |= NonRecursivePrintOption::SkipNonisolatedNonsending;
232234 return options;
233235}
234236
@@ -3895,6 +3897,12 @@ static bool isEscaping(Type type) {
38953897 return false ;
38963898}
38973899
3900+ static bool isNonisolatedCaller (Type type) {
3901+ if (auto *funcTy = type->getAs <AnyFunctionType>())
3902+ return funcTy->getIsolation ().isNonIsolatedCaller ();
3903+ return false ;
3904+ }
3905+
38983906static void printParameterFlags (ASTPrinter &printer,
38993907 const PrintOptions &options,
39003908 const ParamDecl *param,
@@ -4077,17 +4085,6 @@ void PrintAST::printOneParameter(const ParamDecl *param,
40774085
40784086 auto interfaceTy = param->getInterfaceType ();
40794087
4080- // If type of this parameter is isolated to a caller, let's
4081- // strip the isolation from the type to avoid printing it as
4082- // part of the function type because that would break ordering
4083- // between specifiers and attributes.
4084- if (param->isCallerIsolated ()) {
4085- if (auto *funcTy = dyn_cast<AnyFunctionType>(interfaceTy.getPointer ())) {
4086- interfaceTy =
4087- funcTy->withIsolation (FunctionTypeIsolation::forNonIsolated ());
4088- }
4089- }
4090-
40914088 TypeLoc TheTypeLoc;
40924089 if (auto *repr = param->getTypeRepr ()) {
40934090 TheTypeLoc = TypeLoc (repr, interfaceTy);
@@ -4108,7 +4105,7 @@ void PrintAST::printOneParameter(const ParamDecl *param,
41084105 // be written explicitly in this position.
41094106 printParameterFlags (Printer, Options, param, paramFlags,
41104107 isEscaping (type) && !isEnumElement,
4111- param-> isCallerIsolated ( ));
4108+ isNonisolatedCaller (interfaceTy ));
41124109 }
41134110
41144111 printTypeLoc (TheTypeLoc, getNonRecursiveOptions (param));
@@ -6629,7 +6626,8 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
66296626 visit (staticSelfT);
66306627 }
66316628
6632- void printFunctionExtInfo (AnyFunctionType *fnType) {
6629+ void printFunctionExtInfo (AnyFunctionType *fnType,
6630+ NonRecursivePrintOptions nrOptions) {
66336631 if (!fnType->hasExtInfo ()) {
66346632 Printer << " @_NO_EXTINFO " ;
66356633 return ;
@@ -6686,6 +6684,9 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
66866684 break ;
66876685
66886686 case FunctionTypeIsolation::Kind::NonIsolatedNonsending:
6687+ if (nrOptions & NonRecursivePrintOption::SkipNonisolatedNonsending)
6688+ break ;
6689+
66896690 Printer << " nonisolated(nonsending) " ;
66906691 break ;
66916692 }
@@ -6938,7 +6939,7 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
69386939 Printer.printStructurePost (PrintStructureKind::FunctionType);
69396940 };
69406941
6941- printFunctionExtInfo (T);
6942+ printFunctionExtInfo (T, nrOptions );
69426943
69436944 // If we're stripping argument labels from types, do it when printing.
69446945 visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ false ,
@@ -6996,7 +6997,7 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
69966997 Printer.printStructurePost (PrintStructureKind::FunctionType);
69976998 };
69986999
6999- printFunctionExtInfo (T);
7000+ printFunctionExtInfo (T, nrOptions );
70007001 printGenericSignature (T->getGenericSignature (),
70017002 PrintAST::PrintParams |
70027003 PrintAST::defaultGenericRequirementFlags (Options));
0 commit comments