Skip to content

Commit c7adca2

Browse files
authored
Merge pull request swiftlang#19525 from xedin/allow-empty-labels-for-special-names
[AST/Printing] Don't omit empty labels in special names
2 parents 6c41168 + 63b802c commit c7adca2

40 files changed

+122
-122
lines changed

lib/AST/Identifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ llvm::raw_ostream &DeclName::print(llvm::raw_ostream &os,
184184
}
185185

186186
llvm::raw_ostream &DeclName::printPretty(llvm::raw_ostream &os) const {
187-
return print(os, /*skipEmptyArgumentNames=*/true);
187+
return print(os, /*skipEmptyArgumentNames=*/!isSpecial());
188188
}
189189

190190
ObjCSelector::ObjCSelector(ASTContext &ctx, unsigned numArgs,

test/ClangImporter/availability.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ func test_unavailable_accessors(_ obj: UnavailableAccessors,
5454
UnavailableAccessors.setterUnavailableClass = 0 // expected-error {{setter for 'setterUnavailableClass' is unavailable}}
5555
UnavailableAccessors.setterUnavailableClass += 1 // expected-error {{setter for 'setterUnavailableClass' is unavailable}}
5656

57-
_ = sub[0] // expected-error {{getter for 'subscript' is unavailable: bad subscript getter}}
58-
sub[0] = "" // expected-error {{setter for 'subscript' is unavailable: bad subscript setter}}
59-
sub[0] += "" // expected-error {{getter for 'subscript' is unavailable: bad subscript getter}} expected-error {{setter for 'subscript' is unavailable: bad subscript setter}}
57+
_ = sub[0] // expected-error {{getter for 'subscript(_:)' is unavailable: bad subscript getter}}
58+
sub[0] = "" // expected-error {{setter for 'subscript(_:)' is unavailable: bad subscript setter}}
59+
sub[0] += "" // expected-error {{getter for 'subscript(_:)' is unavailable: bad subscript getter}} expected-error {{setter for 'subscript(_:)' is unavailable: bad subscript setter}}
6060

61-
_ = subGetter[0] // expected-error {{getter for 'subscript' is unavailable: bad subscript getter}}
61+
_ = subGetter[0] // expected-error {{getter for 'subscript(_:)' is unavailable: bad subscript getter}}
6262
subGetter[0] = ""
63-
subGetter[0] += "" // expected-error {{getter for 'subscript' is unavailable: bad subscript getter}}
63+
subGetter[0] += "" // expected-error {{getter for 'subscript(_:)' is unavailable: bad subscript getter}}
6464

6565
_ = subSetter[0]
66-
subSetter[0] = "" // expected-error {{setter for 'subscript' is unavailable: bad subscript setter}}
67-
subSetter[0] += "" // expected-error {{setter for 'subscript' is unavailable: bad subscript setter}}
66+
subSetter[0] = "" // expected-error {{setter for 'subscript(_:)' is unavailable: bad subscript setter}}
67+
subSetter[0] += "" // expected-error {{setter for 'subscript(_:)' is unavailable: bad subscript setter}}
6868

69-
_ = subReadOnly[0] // expected-error {{getter for 'subscript' is unavailable}}
69+
_ = subReadOnly[0] // expected-error {{getter for 'subscript(_:)' is unavailable}}
7070
}
7171

7272
func test_deprecated(_ s:UnsafeMutablePointer<CChar>, _ obj: AccessorDeprecations,
@@ -100,19 +100,19 @@ func test_deprecated(_ s:UnsafeMutablePointer<CChar>, _ obj: AccessorDeprecation
100100
AccessorDeprecations.setterDeprecatedClass = 0 // expected-warning {{setter for 'setterDeprecatedClass' is deprecated}}
101101
AccessorDeprecations.setterDeprecatedClass += 1 // expected-warning {{setter for 'setterDeprecatedClass' is deprecated}}
102102

103-
_ = sub[0] // expected-warning {{getter for 'subscript' is deprecated: bad subscript getter}}
104-
sub[0] = "" // expected-warning {{setter for 'subscript' is deprecated: bad subscript setter}}
105-
sub[0] += "" // expected-warning {{getter for 'subscript' is deprecated: bad subscript getter}} expected-warning {{setter for 'subscript' is deprecated: bad subscript setter}}
103+
_ = sub[0] // expected-warning {{getter for 'subscript(_:)' is deprecated: bad subscript getter}}
104+
sub[0] = "" // expected-warning {{setter for 'subscript(_:)' is deprecated: bad subscript setter}}
105+
sub[0] += "" // expected-warning {{getter for 'subscript(_:)' is deprecated: bad subscript getter}} expected-warning {{setter for 'subscript(_:)' is deprecated: bad subscript setter}}
106106

107-
_ = subGetter[0] // expected-warning {{getter for 'subscript' is deprecated: bad subscript getter}}
107+
_ = subGetter[0] // expected-warning {{getter for 'subscript(_:)' is deprecated: bad subscript getter}}
108108
subGetter[0] = ""
109-
subGetter[0] += "" // expected-warning {{getter for 'subscript' is deprecated: bad subscript getter}}
109+
subGetter[0] += "" // expected-warning {{getter for 'subscript(_:)' is deprecated: bad subscript getter}}
110110

111111
_ = subSetter[0]
112-
subSetter[0] = "" // expected-warning {{setter for 'subscript' is deprecated: bad subscript setter}}
113-
subSetter[0] += "" // expected-warning {{setter for 'subscript' is deprecated: bad subscript setter}}
112+
subSetter[0] = "" // expected-warning {{setter for 'subscript(_:)' is deprecated: bad subscript setter}}
113+
subSetter[0] += "" // expected-warning {{setter for 'subscript(_:)' is deprecated: bad subscript setter}}
114114

115-
_ = subReadOnly[0] // expected-warning {{getter for 'subscript' is deprecated}}
115+
_ = subReadOnly[0] // expected-warning {{getter for 'subscript(_:)' is deprecated}}
116116
}
117117

118118
func test_NSInvocation(_ x: NSInvocation, // expected-error {{'NSInvocation' is unavailable}}

test/Compatibility/attr_override.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class A {
4040
var v9: Int { return 5 } // expected-note{{attempt to override property here}}
4141
var v10: Int { return 5 } // expected-note{{attempt to override property here}}
4242

43-
subscript (i: Int) -> String { // expected-note{{potential overridden subscript 'subscript' here}}
43+
subscript (i: Int) -> String { // expected-note{{potential overridden subscript 'subscript(_:)' here}}
4444
get {
4545
return "hello"
4646
}
@@ -49,7 +49,7 @@ class A {
4949
}
5050
}
5151

52-
subscript (d: Double) -> String { // expected-note{{overridden declaration is here}} expected-note{{potential overridden subscript 'subscript' here}}
52+
subscript (d: Double) -> String { // expected-note{{overridden declaration is here}} expected-note{{potential overridden subscript 'subscript(_:)' here}}
5353
get {
5454
return "hello"
5555
}
@@ -58,11 +58,11 @@ class A {
5858
}
5959
}
6060

61-
subscript (i: Int8) -> A { // expected-note{{potential overridden subscript 'subscript' here}}
61+
subscript (i: Int8) -> A { // expected-note{{potential overridden subscript 'subscript(_:)' here}}
6262
get { return self }
6363
}
6464

65-
subscript (i: Int16) -> A { // expected-note{{attempt to override subscript here}} expected-note{{potential overridden subscript 'subscript' here}}
65+
subscript (i: Int16) -> A { // expected-note{{attempt to override subscript here}} expected-note{{potential overridden subscript 'subscript(_:)' here}}
6666
get { return self }
6767
set { }
6868
}

test/Compatibility/special_func_name.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct S12 : P1 { // expected-error {{type 'S12' does not conform to protocol 'P
1414
}
1515

1616
protocol P2 {
17-
init(_: Int) // expected-note {{protocol requires initializer 'init' with type 'Int'; do you want to add a stub?}}
17+
init(_: Int) // expected-note {{protocol requires initializer 'init(_:)' with type 'Int'; do you want to add a stub?}}
1818
}
1919

2020
struct S21 : P2 { // expected-error {{type 'S21' does not conform to protocol 'P2'}}

test/Compatibility/tuple_arguments_4.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ do {
513513
}
514514

515515
struct InitTwo {
516-
init(_ x: Int, _ y: Int) {} // expected-note 5 {{'init' declared here}}
516+
init(_ x: Int, _ y: Int) {} // expected-note 5 {{'init(_:_:)' declared here}}
517517
}
518518

519519
struct InitTuple {
@@ -564,7 +564,7 @@ do {
564564
}
565565

566566
struct SubscriptTwo {
567-
subscript(_ x: Int, _ y: Int) -> Int { get { return 0 } set { } } // expected-note 5 {{'subscript' declared here}}
567+
subscript(_ x: Int, _ y: Int) -> Int { get { return 0 } set { } } // expected-note 5 {{'subscript(_:_:)' declared here}}
568568
}
569569

570570
struct SubscriptTuple {
@@ -915,7 +915,7 @@ struct GenericInitLabeled<T> {
915915
}
916916

917917
struct GenericInitTwo<T> {
918-
init(_ x: T, _ y: T) {} // expected-note 10 {{'init' declared here}}
918+
init(_ x: T, _ y: T) {} // expected-note 10 {{'init(_:_:)' declared here}}
919919
}
920920

921921
struct GenericInitTuple<T> {
@@ -1041,7 +1041,7 @@ struct GenericSubscriptLabeled<T> {
10411041
}
10421042

10431043
struct GenericSubscriptTwo<T> {
1044-
subscript(_ x: T, _ y: T) -> Int { get { return 0 } set { } } // expected-note 5 {{'subscript' declared here}}
1044+
subscript(_ x: T, _ y: T) -> Int { get { return 0 } set { } } // expected-note 5 {{'subscript(_:_:)' declared here}}
10451045
}
10461046

10471047
struct GenericSubscriptLabeledTuple<T> {

test/Constraints/diag_ambiguities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func g(_ x: Int, _ y: Int) -> () {} // expected-note{{found this candidate}}
2727
C(g) // expected-error{{ambiguous use of 'g'}}
2828

2929
func h<T>(_ x: T) -> () {}
30-
C(h) // expected-error{{ambiguous use of 'init'}}
30+
C(h) // expected-error{{ambiguous use of 'init(_:)'}}
3131

3232
func rdar29691909_callee(_ o: AnyObject?) -> Any? { return o } // expected-note {{found this candidate}}
3333
func rdar29691909_callee(_ o: AnyObject) -> Any { return o } // expected-note {{found this candidate}}

test/Constraints/diagnostics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func r23641896() {
681681
var g = "Hello World"
682682
g.replaceSubrange(0...2, with: "ce") // expected-error {{cannot convert value of type 'ClosedRange<Int>' to expected argument type 'Range<String.Index>'}}
683683

684-
_ = g[12] // expected-error {{'subscript' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion}}
684+
_ = g[12] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion}}
685685

686686
}
687687

@@ -1199,7 +1199,7 @@ func platypus<T>(a: [T]) {
11991199
func badTypes() {
12001200
let sequence:AnySequence<[Int]> = AnySequence() { AnyIterator() { [3] }}
12011201
let array = [Int](sequence)
1202-
// expected-error@-1 {{initializer 'init' requires the types 'Int' and '[Int]' be equivalent}}
1202+
// expected-error@-1 {{initializer 'init(_:)' requires the types 'Int' and '[Int]' be equivalent}}
12031203
}
12041204

12051205
// rdar://34357545

test/Constraints/generics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ struct V27515965 {
253253

254254
func test(x: S27515965) -> V27515965 {
255255
return V27515965(x)
256-
// expected-error@-1 {{initializer 'init' requires the types 'Any' and 'Float' be equivalent}}
256+
// expected-error@-1 {{initializer 'init(_:)' requires the types 'Any' and 'Float' be equivalent}}
257257
}
258258

259259
protocol BaseProto {}

test/Constraints/lvalues.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ r23331567 { $0 += 1 }
233233
// <rdar://problem/30685195> Compiler crash with invalid assignment
234234
struct G<T> {
235235
subscript(x: Int) -> T { get { } nonmutating set { } }
236-
// expected-note@-1 {{'subscript' declared here}}
236+
// expected-note@-1 {{'subscript(_:)' declared here}}
237237
}
238238

239239
func wump<T>(to: T, _ body: (G<T>) -> ()) {}

test/Constraints/rdar44569159.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ struct A {
1313

1414
func foo(_ v: Double) {
1515
_ = A()[S(value: v)]
16-
// expected-error@-1 {{subscript 'subscript' requires that 'Double' conform to 'P'}}
16+
// expected-error@-1 {{subscript 'subscript(_:)' requires that 'Double' conform to 'P'}}
1717
// expected-error@-2 {{referencing initializer 'init(value:)' on 'S' requires that 'Double' conform to 'P'}}
1818
}

0 commit comments

Comments
 (0)