File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -3821,14 +3821,28 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3821
3821
3822
3822
printFunctionExtInfo (T->getExtInfo ());
3823
3823
3824
+ // If we're stripping argument labels from types, do it when printing.
3825
+ Type inputType = T->getInput ();
3826
+ if (inputType->getASTContext ().LangOpts .SuppressArgumentLabelsInTypes ) {
3827
+ if (auto tupleTy = dyn_cast<TupleType>(inputType.getPointer ())) {
3828
+ SmallVector<TupleTypeElt, 4 > elements;
3829
+ elements.reserve (tupleTy->getNumElements ());
3830
+ for (const auto &elt : tupleTy->getElements ()) {
3831
+ elements.push_back (TupleTypeElt (elt.getType (), Identifier (),
3832
+ elt.isVararg ()));
3833
+ }
3834
+ inputType = TupleType::get (elements, inputType->getASTContext ());
3835
+ }
3836
+ }
3837
+
3824
3838
bool needsParens =
3825
- !isa<ParenType>(T-> getInput () .getPointer ()) &&
3826
- !T-> getInput () ->is <TupleType>();
3839
+ !isa<ParenType>(inputType .getPointer ()) &&
3840
+ !inputType ->is <TupleType>();
3827
3841
3828
3842
if (needsParens)
3829
3843
Printer << " (" ;
3830
3844
3831
- visit (T-> getInput () );
3845
+ visit (inputType );
3832
3846
3833
3847
if (needsParens)
3834
3848
Printer << " )" ;
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -emit-silgen -suppress-argument-labels-in-types %s | FileCheck %s
2
+
3
+ public struct X { }
4
+ public struct Y { }
5
+
6
+ public class Foo {
7
+ func doSomething( x: X , y: Y ) { }
8
+ func doSomethingElse( x: X ) { }
9
+ }
10
+
11
+ // CHECK-LABEL: sil hidden @_TF15argument_labels7testFoo
12
+ func testFoo( foo: Foo , x: X , y: Y ) {
13
+ // CHECK: class_method %0 : $Foo, #Foo.doSomething!1 : (Foo) -> (X, Y) -> ()
14
+ foo. doSomething ( x: x, y: y)
15
+
16
+ // CHECK: class_method %0 : $Foo, #Foo.doSomethingElse!1 : (Foo) -> (X) -> ()
17
+ foo. doSomethingElse ( x: x)
18
+ }
19
+
You can’t perform that action at this time.
0 commit comments