Skip to content

Commit 185317f

Browse files
authored
Merge pull request #32779 from rintaro/ide-completion-closureplaceholder-rdar63607976
[PlaceholderExpansion] Omit return type in closure signature
2 parents 28e7bc6 + 17be66c commit 185317f

File tree

7 files changed

+44
-76
lines changed

7 files changed

+44
-76
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,10 +1016,6 @@ void CodeCompletionResultBuilder::addCallParameter(Identifier Name,
10161016
SmallString<32> buffer;
10171017
llvm::raw_svector_ostream OS(buffer);
10181018

1019-
bool returnsVoid = AFT->getResult()->isVoid();
1020-
bool hasSignature = !returnsVoid || !AFT->getParams().empty();
1021-
if (hasSignature)
1022-
OS << "(";
10231019
bool firstParam = true;
10241020
for (const auto &param : AFT->getParams()) {
10251021
if (!firstParam)
@@ -1038,12 +1034,8 @@ void CodeCompletionResultBuilder::addCallParameter(Identifier Name,
10381034
OS << "#>";
10391035
}
10401036
}
1041-
if (hasSignature)
1042-
OS << ")";
1043-
if (!returnsVoid)
1044-
OS << " -> " << AFT->getResult()->getString(PO);
10451037

1046-
if (hasSignature)
1038+
if (!firstParam)
10471039
OS << " in";
10481040

10491041
addChunkWithText(

test/IDE/complete_multiple_trailingclosure.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func testGlobalFunc() {
2424
{ 1 } #^GLOBALFUNC_SAMELINE^#
2525
#^GLOBALFUNC_NEWLINE^#
2626
// GLOBALFUNC_SAMELINE: Begin completions, 1 items
27-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
27+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
2828
// GLOBALFUNC_SAMELINE: End completions
2929

3030
// GLOBALFUNC_NEWLINE: Begin completions, 1 items
31-
// GLOBALFUNC_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
31+
// GLOBALFUNC_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
3232
// GLOBALFUNC_NEWLINE: End completions
3333

3434
globalFunc1()
@@ -53,14 +53,14 @@ func testMethod(value: MyStruct) {
5353
} #^METHOD_SAMELINE^#
5454
#^METHOD_NEWLINE^#
5555
// METHOD_SAMELINE: Begin completions, 4 items
56-
// METHOD_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {() -> String in|}#}[#(() -> String)?#];
56+
// METHOD_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {|}#}[#(() -> String)?#];
5757
// METHOD_SAMELINE-DAG: Decl[InstanceMethod]/CurrNominal: .enumFunc()[#Void#];
5858
// METHOD_SAMELINE-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]/IsSystem: [' ']+ {#SimpleEnum#}[#SimpleEnum#];
5959
// METHOD_SAMELINE-DAG: Keyword[self]/CurrNominal: .self[#SimpleEnum#];
6060
// METHOD_SAMELINE: End completions
6161

6262
// METHOD_NEWLINE: Begin completions
63-
// METHOD_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {() -> String in|}#}[#(() -> String)?#];
63+
// METHOD_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {|}#}[#(() -> String)?#];
6464
// METHOD_NEWLINE-DAG: Keyword[class]/None: class;
6565
// METHOD_NEWLINE-DAG: Keyword[if]/None: if;
6666
// METHOD_NEWLINE-DAG: Keyword[try]/None: try;
@@ -84,15 +84,15 @@ func testOverloadedInit() {
8484
#^INIT_OVERLOADED_NEWLINE^#
8585

8686
// INIT_OVERLOADED_SAMELINE: Begin completions, 4 items
87-
// INIT_OVERLOADED_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
88-
// INIT_OVERLOADED_SAMELINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {() -> String in|}#}[#() -> String#];
87+
// INIT_OVERLOADED_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
88+
// INIT_OVERLOADED_SAMELINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {|}#}[#() -> String#];
8989
// INIT_OVERLOADED_SAMELINE-DAG: Decl[InstanceMethod]/CurrNominal: .testStructMethod()[#Void#];
9090
// INIT_OVERLOADED_SAMELINE-DAG: Keyword[self]/CurrNominal: .self[#TestStruct#];
9191
// INIT_OVERLOADED_SAMELINE: End completions
9292

9393
// INIT_OVERLOADED_NEWLINE: Begin completions
94-
// INIT_OVERLOADED_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
95-
// INIT_OVERLOADED_NEWLINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {() -> String in|}#}[#() -> String#];
94+
// INIT_OVERLOADED_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
95+
// INIT_OVERLOADED_NEWLINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {|}#}[#() -> String#];
9696
// INIT_OVERLOADED_NEWLINE-DAG: Keyword[class]/None: class;
9797
// INIT_OVERLOADED_NEWLINE-DAG: Keyword[if]/None: if;
9898
// INIT_OVERLOADED_NEWLINE-DAG: Keyword[try]/None: try;
@@ -111,15 +111,15 @@ func testOptionalInit() {
111111
#^INIT_OPTIONAL_NEWLINE^#
112112

113113
// INIT_OPTIONAL_SAMELINE: Begin completions, 4 items
114-
// INIT_OPTIONAL_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
115-
// INIT_OPTIONAL_SAMELINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {() -> String in|}#}[#() -> String#];
114+
// INIT_OPTIONAL_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
115+
// INIT_OPTIONAL_SAMELINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {|}#}[#() -> String#];
116116
// INIT_OPTIONAL_SAMELINE-DAG: Decl[InstanceMethod]/CurrNominal: .testStructMethod()[#Void#];
117117
// INIT_OPTIONAL_SAMELINE-DAG: Keyword[self]/CurrNominal: .self[#TestStruct2#];
118118
// INIT_OPTIONAL_SAMELINE: End completions
119119

120120
// INIT_OPTIONAL_NEWLINE: Begin completions
121-
// INIT_OPTIONAL_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
122-
// INIT_OPTIONAL_NEWLINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {() -> String in|}#}[#() -> String#];
121+
// INIT_OPTIONAL_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
122+
// INIT_OPTIONAL_NEWLINE-DAG: Pattern/ExprSpecific: {#fn3: () -> String {|}#}[#() -> String#];
123123
// INIT_OPTIONAL_NEWLINE-DAG: Keyword[class]/None: class;
124124
// INIT_OPTIONAL_NEWLINE-DAG: Keyword[if]/None: if;
125125
// INIT_OPTIONAL_NEWLINE-DAG: Keyword[try]/None: try;
@@ -139,11 +139,11 @@ func testOptionalInit() {
139139
#^INIT_REQUIRED_NEWLINE_1^#
140140

141141
// INIT_REQUIRED_SAMELINE_1: Begin completions, 1 items
142-
// INIT_REQUIRED_SAMELINE_1-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
142+
// INIT_REQUIRED_SAMELINE_1-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
143143
// INIT_REQUIRED_SAMELINE_1: End completions
144144

145145
// INIT_REQUIRED_NEWLINE_1: Begin completions, 1 items
146-
// INIT_REQUIRED_NEWLINE_1-DAG: Pattern/ExprSpecific: {#fn2: () -> String {() -> String in|}#}[#() -> String#];
146+
// INIT_REQUIRED_NEWLINE_1-DAG: Pattern/ExprSpecific: {#fn2: () -> String {|}#}[#() -> String#];
147147
// INIT_REQUIRED_NEWLINE_1: End completions
148148

149149
// missing 'fn3'.
@@ -155,11 +155,11 @@ func testOptionalInit() {
155155
#^INIT_REQUIRED_NEWLINE_2^#
156156

157157
// INIT_REQUIRED_SAMELINE_2: Begin completions, 1 items
158-
// INIT_REQUIRED_SAMELINE_2-DAG: Pattern/ExprSpecific: {#fn3: () -> String {() -> String in|}#}[#() -> String#];
158+
// INIT_REQUIRED_SAMELINE_2-DAG: Pattern/ExprSpecific: {#fn3: () -> String {|}#}[#() -> String#];
159159
// INIT_REQUIRED_SAMELINE_2: End completions
160160

161161
// INIT_REQUIRED_NEWLINE_2: Begin completions, 1 items
162-
// INIT_REQUIRED_NEWLINE_2-DAG: Pattern/ExprSpecific: {#fn3: () -> String {() -> String in|}#}[#() -> String#];
162+
// INIT_REQUIRED_NEWLINE_2-DAG: Pattern/ExprSpecific: {#fn3: () -> String {|}#}[#() -> String#];
163163
// INIT_REQUIRED_NEWLINE_2: End completions
164164

165165
// Call is completed.
@@ -218,14 +218,14 @@ struct TestNominalMember: P {
218218
#^MEMBERDECL_NEWLINE^#
219219

220220
// MEMBERDECL_SAMELINE: Begin completions, 4 items
221-
// MEMBERDECL_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {() -> String in|}#}[#(() -> String)?#]; name=fn2: (() -> String)?
221+
// MEMBERDECL_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {|}#}[#(() -> String)?#]; name=fn2: (() -> String)?
222222
// MEMBERDECL_SAMELINE-DAG: Decl[InstanceMethod]/CurrNominal: .enumFunc()[#Void#]; name=enumFunc()
223223
// MEMBERDECL_SAMELINE-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]/IsSystem: [' ']+ {#SimpleEnum#}[#SimpleEnum#]; name=+ SimpleEnum
224224
// MEMBERDECL_SAMELINE-DAG: Keyword[self]/CurrNominal: .self[#SimpleEnum#]; name=self
225225
// MEMBERDECL_SAMELINE: End completions
226226

227227
// MEMBERDECL_NEWLINE: Begin completions
228-
// MEMBERDECL_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {() -> String in|}#}[#(() -> String)?#]; name=fn2: (() -> String)?
228+
// MEMBERDECL_NEWLINE-DAG: Pattern/ExprSpecific: {#fn2: (() -> String)? {|}#}[#(() -> String)?#]; name=fn2: (() -> String)?
229229
// MEMBERDECL_NEWLINE-DAG: Keyword[enum]/None: enum; name=enum
230230
// MEMBERDECL_NEWLINE-DAG: Keyword[func]/None: func; name=func
231231
// MEMBERDECL_NEWLINE-DAG: Keyword[private]/None: private; name=private

test/IDE/complete_multiple_trailingclosure_signatures.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func test() {
1717

1818
// GLOBALFUNC_SAMELINE: Begin completions
1919
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn2: () -> Void {|}#}[#() -> Void#];
20-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn3: (Int) -> Void {(<#Int#>) in|}#}[#(Int) -> Void#];
21-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn4: (Int, String) -> Void {(<#Int#>, <#String#>) in|}#}[#(Int, String) -> Void#];
22-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn5: (Int, String) -> Int {(<#Int#>, <#String#>) -> Int in|}#}[#(Int, String) -> Int#];
20+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn3: (Int) -> Void {<#Int#> in|}#}[#(Int) -> Void#];
21+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn4: (Int, String) -> Void {<#Int#>, <#String#> in|}#}[#(Int, String) -> Void#];
22+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn5: (Int, String) -> Int {<#Int#>, <#String#> in|}#}[#(Int, String) -> Int#];
2323
// FIXME: recover names
24-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn6: (Int, String) -> Int {(<#Int#>, <#String#>) -> Int in|}#}[#(Int, String) -> Int#];
25-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn7: (inout Int) -> Void {(<#inout Int#>) in|}#}[#(inout Int) -> Void#];
26-
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn8: (Int...) -> Void {(<#Int...#>) in|}#}[#(Int...) -> Void#];
24+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn6: (Int, String) -> Int {<#Int#>, <#String#> in|}#}[#(Int, String) -> Int#];
25+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn7: (inout Int) -> Void {<#inout Int#> in|}#}[#(inout Int) -> Void#];
26+
// GLOBALFUNC_SAMELINE-DAG: Pattern/ExprSpecific: {#fn8: (Int...) -> Void {<#Int...#> in|}#}[#(Int...) -> Void#];
2727
// GLOBALFUNC_SAMELINE: End completions
2828
}

test/SourceKit/CodeComplete/multiple_trailing_closure_signatures.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func func1(
1919

2020
// CHECK: key.results: [
2121
// CHECK-DAG: key.sourcetext: "fn2: {\n<#code#>\n}"
22-
// CHECK-DAG: key.sourcetext: "fn3: { (<#Int#>) in\n<#code#>\n}"
23-
// CHECK-DAG: key.sourcetext: "fn4: { (<#Int#>, <#String#>) in\n<#code#>\n}",
24-
// CHECK-DAG: key.sourcetext: "fn5: { (<#Int#>, <#String#>) -> Int in\n<#code#>\n}",
25-
// CHECK-DAG: key.sourcetext: "fn7: { (<#inout Int#>) in\n<#code#>\n}",
26-
// CHECK-DAG: key.sourcetext: "fn8: { (<#Int...#>) in\n<#code#>\n}",
22+
// CHECK-DAG: key.sourcetext: "fn3: { <#Int#> in\n<#code#>\n}"
23+
// CHECK-DAG: key.sourcetext: "fn4: { <#Int#>, <#String#> in\n<#code#>\n}",
24+
// CHECK-DAG: key.sourcetext: "fn5: { <#Int#>, <#String#> in\n<#code#>\n}",
25+
// CHECK-DAG: key.sourcetext: "fn7: { <#inout Int#> in\n<#code#>\n}",
26+
// CHECK-DAG: key.sourcetext: "fn8: { <#Int...#> in\n<#code#>\n}",
2727
// CHECK: ]
2828

2929
// DESCRIPTION-NOT: key.description: "fn{{[0-9]*}}: {

test/SourceKit/CodeExpand/code-expand-multiple-trailing-closures.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ nonTrailingAndTrailing2(a: <#T##() -> ()#>, b: <#T##Int#> c: <#T##() -> ()#>)
8989

9090

9191
withTypesAndLabels1(a: <#T##(_ booly: Bool, inty: Int) -> ()#>, b: <#T##(solo: Xyz) -> ()#>)
92-
// CHECK: withTypesAndLabels1 { (booly, inty) in
92+
// CHECK: withTypesAndLabels1 { booly, inty in
9393
// CHECK-NEXT: <#code#>
94-
// CHECK-NEXT: } b: { (solo) in
94+
// CHECK-NEXT: } b: { solo in
9595
// CHECK-NEXT: <#code#>
9696
// CHECK-NEXT: }
9797

9898
func reset_parser1() {}
9999

100100
withTypes1(a: <#T##(Bool, Int) -> ()#>, b: <#T##() -> Int#>)
101-
// CHECK: withTypes1 { (<#Bool#>, <#Int#>) in
101+
// CHECK: withTypes1 { <#Bool#>, <#Int#> in
102102
// CHECK-NEXT: <#code#>
103-
// CHECK-NEXT: } b: { () -> Int in
103+
// CHECK-NEXT: } b: {
104104
// CHECK-NEXT: <#code#>
105105
// CHECK-NEXT: }
106106

test/SourceKit/CodeExpand/code-expand.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ foo(x: <#T##() -> Void#>, y: <#T##Int#>)
1111
// CHECK-NEXT: }, y: Int)
1212

1313
anArr.indexOfObjectPassingTest(<#T##predicate: ((AnyObject!, Int, UnsafePointer<ObjCBool>) -> Bool)?##((AnyObject!, Int, UnsafePointer<ObjCBool>) -> Bool)?#>)
14-
// CHECK: anArr.indexOfObjectPassingTest { (<#AnyObject!#>, <#Int#>, <#UnsafePointer<ObjCBool>#>) -> Bool in
14+
// CHECK: anArr.indexOfObjectPassingTest { <#AnyObject!#>, <#Int#>, <#UnsafePointer<ObjCBool>#> in
1515
// CHECK-NEXT: <#code#>
1616
// CHECK-NEXT: }
1717

1818
anArr.indexOfObjectPassingTest(<#T##predicate: ((_ obj: AnyObject!, _ idx: Int, _ stop: UnsafePointer<ObjCBool>) -> Bool)?##((_ obj: AnyObject!, _ idx: Int, _ stop: UnsafePointer<ObjCBool>) -> Bool)?#>)
19-
// CHECK: anArr.indexOfObjectPassingTest { (obj, idx, stop) -> Bool in
19+
// CHECK: anArr.indexOfObjectPassingTest { obj, idx, stop in
2020
// CHECK-NEXT: <#code#>
2121
// CHECK-NEXT: }
2222

2323
anArr.indexOfObjectAtIndexes(<#T##s: NSIndexSet?##NSIndexSet?#>, options: <#T##NSEnumerationOptions#>, passingTest: <#T##((AnyObject!, Int, UnsafePointer<ObjCBool>) -> Bool)?#>)
24-
// CHECK: anArr.indexOfObjectAtIndexes(NSIndexSet?, options: NSEnumerationOptions) { (<#AnyObject!#>, <#Int#>, <#UnsafePointer<ObjCBool>#>) -> Bool in
24+
// CHECK: anArr.indexOfObjectAtIndexes(NSIndexSet?, options: NSEnumerationOptions) { <#AnyObject!#>, <#Int#>, <#UnsafePointer<ObjCBool>#> in
2525
// CHECK-NEXT: <#code#>
2626
// CHECK-NEXT: }
2727

2828
if anArr.indexOfObjectPassingTest(<#T##predicate: ((AnyObject!, Int, UnsafePointer<ObjCBool>) -> Bool)?##((AnyObject!, Int, UnsafePointer<ObjCBool>) -> Bool)?#>) {
2929
}
30-
// CHECK: if anArr.indexOfObjectPassingTest({ (<#AnyObject!#>, <#Int#>, <#UnsafePointer<ObjCBool>#>) -> Bool in
30+
// CHECK: if anArr.indexOfObjectPassingTest({ <#AnyObject!#>, <#Int#>, <#UnsafePointer<ObjCBool>#> in
3131
// CHECK-NEXT: <#code#>
3232
// CHECK-NEXT: }) {
3333
// CHECK-NEXT: }
@@ -48,10 +48,10 @@ do {
4848
}
4949

5050
foo(x: <#T##Self.SegueIdentifier -> Void#>)
51-
// CHECK: foo { (<#Self.SegueIdentifier#>) in
51+
// CHECK: foo { <#Self.SegueIdentifier#> in
5252

5353
store.requestAccessToEntityType(<#T##entityType: EKEntityType##EKEntityType#>, completion: <#T##EKEventStoreRequestAccessCompletionHandler##EKEventStoreRequestAccessCompletionHandler##(Bool, NSError?) -> Void#>)
54-
// CHECK: store.requestAccessToEntityType(EKEntityType) { (<#Bool#>, <#NSError?#>) in
54+
// CHECK: store.requestAccessToEntityType(EKEntityType) { <#Bool#>, <#NSError?#> in
5555
// CHECK-NEXT: <#code#>
5656
// CHECK-NEXT: }
5757

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,54 +2129,30 @@ void SwiftEditorDocument::formatText(unsigned Line, unsigned Length,
21292129
Consumer.recordAffectedLineRange(LineRange.startLine(), LineRange.lineCount());
21302130
}
21312131

2132-
bool isReturningVoid(const SourceManager &SM, CharSourceRange Range) {
2133-
if (Range.isInvalid())
2134-
return false;
2135-
StringRef Text = SM.extractText(Range);
2136-
return "()" == Text || "Void" == Text;
2137-
}
2138-
21392132
static void
21402133
printClosureBody(const PlaceholderExpansionScanner::ClosureInfo &closure,
21412134
llvm::raw_ostream &OS, const SourceManager &SM) {
2142-
bool ReturningVoid = isReturningVoid(SM, closure.ReturnTypeRange);
2143-
2144-
bool HasSignature = !closure.Params.empty() ||
2145-
(closure.ReturnTypeRange.isValid() && !ReturningVoid);
21462135
bool FirstParam = true;
2147-
if (HasSignature)
2148-
OS << "(";
21492136
for (auto &Param : closure.Params) {
21502137
if (!FirstParam)
21512138
OS << ", ";
21522139
FirstParam = false;
21532140
if (Param.NameRange.isValid()) {
21542141
// If we have a parameter name, just output the name as is and skip
21552142
// the type. For example:
2156-
// <#(arg1: Int, arg2: Int)#> turns into (arg1, arg2).
2143+
// <#(arg1: Int, arg2: Int)#> turns into '{ arg1, arg2 in'.
21572144
OS << SM.extractText(Param.NameRange);
21582145
} else {
21592146
// If we only have the parameter type, output the type as a
21602147
// placeholder. For example:
2161-
// <#(Int, Int)#> turns into (<#Int#>, <#Int#>).
2148+
// <#(Int, Int)#> turns into '{ <#Int#>, <#Int#> in'.
21622149
OS << "<#";
21632150
OS << SM.extractText(Param.TypeRange);
21642151
OS << "#>";
21652152
}
21662153
}
2167-
if (HasSignature)
2168-
OS << ") ";
2169-
if (closure.ReturnTypeRange.isValid()) {
2170-
auto ReturnTypeText = SM.extractText(closure.ReturnTypeRange);
2171-
2172-
// We need return type if it is not Void.
2173-
if (!ReturningVoid) {
2174-
OS << "-> ";
2175-
OS << ReturnTypeText << " ";
2176-
}
2177-
}
2178-
if (HasSignature)
2179-
OS << "in";
2154+
if (!FirstParam)
2155+
OS << " in";
21802156
OS << "\n" << getCodePlaceholder() << "\n";
21812157
}
21822158

0 commit comments

Comments
 (0)