Skip to content

Commit 0ddf475

Browse files
committed
ASTDemangler: Propagate @escaping from function type to function parameter
1 parent 1731a48 commit 0ddf475

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ Type ASTBuilder::createFunctionType(
313313
.withVariadic(flags.isVariadic())
314314
.withAutoClosure(flags.isAutoClosure());
315315

316+
if (auto *fnType = type->getAs<FunctionType>())
317+
if (!fnType->isNoEscape())
318+
parameterFlags = parameterFlags.withEscaping(true);
319+
316320
funcParams.push_back(AnyFunctionType::Param(type, label, parameterFlags));
317321
}
318322

test/TypeDecoder/structural_types.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ do {
116116
blackHole(metatype)
117117
}
118118

119+
do {
120+
let escaping: (@escaping () -> ()) -> () = { _ in }
121+
blackHole(escaping)
122+
}
119123
// DEMANGLE: $syycD
120124
// DEMANGLE: $sySSzcD
121125
// DEMANGLE: $sySSncD
@@ -131,6 +135,7 @@ do {
131135
// DEMANGLE: $sSi_SfSitD
132136
// DEMANGLE: $sSim_Sf1xSitD
133137
// DEMANGLE: $sSi1x_SfSim1ytD
138+
// DEMANGLE: $syyyccD
134139

135140
// CHECK: () -> ()
136141
// CHECK: (inout String) -> ()
@@ -147,6 +152,7 @@ do {
147152
// CHECK: (Int, Float, Int)
148153
// CHECK: (Int.Type, x: Float, Int)
149154
// CHECK: (x: Int, Float, y: Int.Type)
155+
// CHECK: (@escaping () -> ()) -> ()
150156

151157
// DEMANGLE: $sSimD
152158
// DEMANGLE: $syycmD
@@ -164,6 +170,7 @@ do {
164170
// DEMANGLE: $sSi_SfSitmD
165171
// DEMANGLE: $sSim_Sf1xSitmD
166172
// DEMANGLE: $sSi1x_SfSim1ytmD
173+
// DEMANGLE: $syyyccmD
167174

168175
// CHECK: Int.Type
169176
// CHECK: ((inout String) -> ()).Type
@@ -180,3 +187,4 @@ do {
180187
// CHECK: (Int, Float, Int).Type
181188
// CHECK: (Int.Type, x: Float, Int).Type
182189
// CHECK: (x: Int, Float, y: Int.Type).Type
190+
// CHECK: ((@escaping () -> ()) -> ()).Type

0 commit comments

Comments
 (0)