Skip to content

Commit ae49b69

Browse files
committed
Mangling: fix mangling of functions with a single empty tuple argument
For example: func testit(_ x: ()) -> Int
1 parent 7be3a14 commit ae49b69

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,11 +1351,13 @@ void ASTMangler::appendParams(Type ParamsTy, bool forceSingleParam) {
13511351
if (Tuple->getNumElements() == 0) {
13521352
if (forceSingleParam) {
13531353
// A tuple containing a single empty tuple.
1354+
appendOperator("y");
13541355
appendOperator("t");
13551356
appendListSeparator();
13561357
appendOperator("t");
1358+
} else {
1359+
appendOperator("y");
13571360
}
1358-
appendOperator("y");
13591361
return;
13601362
}
13611363
if (forceSingleParam && Tuple->getNumElements() > 1) {

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,5 @@ _T08mangling14varargsVsArrayySaySiG3arrd_tF ---> mangling.varargsVsArray(arr: Sw
251251
_T0s13_UnicodeViewsVss22RandomAccessCollectionRzs0A8EncodingR_11SubSequence_5IndexQZAFRtzsAcERpzAE_AEQZAIRSs15UnsignedInteger8Iterator_7ElementRPzAE_AlMQZANRS13EncodedScalar_AlMQY_AORSr0_lE13CharacterViewVyxq__G ---> (extension in Swift):Swift._UnicodeViews<A, B><A, B where A: Swift.RandomAccessCollection, B: Swift.UnicodeEncoding, A.Index == A.SubSequence.Index, A.SubSequence: Swift.RandomAccessCollection, A.SubSequence == A.SubSequence.SubSequence, A.Iterator.Element: Swift.UnsignedInteger, A.Iterator.Element == A.SubSequence.Iterator.Element, A.SubSequence.Iterator.Element == B.EncodedScalar.Iterator.Element>.CharacterView
252252
_T010Foundation11MeasurementV12SimulatorKitSo9UnitAngleCRszlE11OrientationO2eeoiSbAcDEAGOyAF_G_AKtFZ ---> static (extension in SimulatorKit):Foundation.Measurement<A where A == __C.UnitAngle>.Orientation.== infix((extension in SimulatorKit):Foundation.Measurement<__C.UnitAngle>.Orientation, (extension in SimulatorKit):Foundation.Measurement<__C.UnitAngle>.Orientation) -> Swift.Bool
253253
_T04main1_yyF ---> main._() -> ()
254+
_T04test6testitSiyt_tF ---> test.testit(()) -> Swift.Int
255+

test/SILGen/arguments_as_tuple_overloads.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public func test(_ a: Int, _ b: Int) {
2828
public func test(_ t: (Int, Int)) {
2929
}
3030

31-
// CHECK: sil @_T04test3fooyt_tyF :
31+
// CHECK: sil @_T04test3fooyyt_tF :
3232
public func foo(_: ()) {
3333
}
3434

0 commit comments

Comments
 (0)