Skip to content

Commit 1ffe97f

Browse files
committed
[Diagnostics] NFC: Adjust more tests improved by extraneous argument(s) fix
1 parent 989b573 commit 1ffe97f

File tree

11 files changed

+30
-35
lines changed

11 files changed

+30
-35
lines changed

test/ClangImporter/objc_factory_method.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ func testInstanceTypeFactoryMethodInherited() {
2323
_ = NSObjectFactorySub(integer: 1)
2424
_ = NSObjectFactorySub(double: 314159)
2525
_ = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}}
26-
let a = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{argument labels '(buildingWidgets:)' do not match any available overloads}}
27-
// expected-note @-1 {{overloads for 'NSObjectFactorySub' exist with these partially matching parameter lists: (double: Double), (integer: Int)}}
26+
let a = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{argument passed to call that takes no arguments}}
2827
_ = a
2928
}
3029

@@ -76,8 +75,7 @@ func testNSErrorFactoryMethod(_ path: String) throws {
7675
}
7776

7877
func testNonInstanceTypeFactoryMethod(_ s: String) {
79-
_ = NSObjectFactory(string: s) // expected-error{{argument labels '(string:)' do not match any available overloads}}
80-
// expected-note @-1 {{(double: Double), (float: Float), (integer: Int)}}
78+
_ = NSObjectFactory(string: s) // expected-error{{argument passed to call that takes no arguments}}
8179
}
8280

8381
func testUseOfFactoryMethod(_ queen: Bee) {

test/ClangImporter/objc_implicit_with.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ func testInstanceTypeFactoryMethodInherited() {
3434
_ = NSObjectFactorySub(integer: 1)
3535
_ = NSObjectFactorySub(double: 314159)
3636
_ = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}}
37-
let a = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{argument labels '(buildingWidgets:)' do not match any available overloads}}
38-
// expected-note @-1 {{overloads for 'NSObjectFactorySub' exist with these partially matching parameter lists: (double: Double), (integer: Int)}}
37+
let a = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{argument passed to call that takes no arguments}}
3938
_ = a
4039
}
4140

@@ -44,8 +43,7 @@ func testNSErrorFactoryMethod(_ path: String) throws {
4443
}
4544

4645
func testNonInstanceTypeFactoryMethod(_ s: String) {
47-
_ = NSObjectFactory(string: s) // expected-error{{argument labels '(string:)' do not match any available overloads}}
48-
// expected-note @-1 {{overloads for 'NSObjectFactory' exist with these partially matching parameter lists: (double: Double), (float: Float), (integer: Int)}}
46+
_ = NSObjectFactory(string: s) // expected-error{{argument passed to call that takes no arguments}}
4947
}
5048

5149
func testUseOfFactoryMethod(_ queen: Bee) {

test/Constraints/diagnostics.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ _ = CurriedClass.method3(1, 2) // expected-error {{instance member 'me
452452
// expected-error@-1 {{missing argument label 'b:' in call}}
453453
CurriedClass.method3(c)(1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
454454
CurriedClass.method3(c)(1) // expected-error {{missing argument for parameter 'b' in call}}
455-
CurriedClass.method3(c)(c: 1.0) // expected-error {{missing argument for parameter #1 in call}} expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
455+
CurriedClass.method3(c)(c: 1.0) // expected-error {{incorrect argument labels in call (have 'c:', expected '_:b:')}}
456+
// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}}
456457

457458

458459
extension CurriedClass {
@@ -909,7 +910,7 @@ struct rdar27891805 {
909910
}
910911

911912
try rdar27891805(contentsOfURL: nil, usedEncoding: nil)
912-
// expected-error@-1 {{incorrect argument labels in call (have 'contentsOfURL:usedEncoding:', expected 'contentsOf:encoding:')}}
913+
// expected-error@-1 {{incorrect argument label in call (have 'contentsOfURL:usedEncoding:', expected 'contentsOf:usedEncoding:')}}
913914
// expected-error@-2 {{'nil' is not compatible with expected argument type 'String'}}
914915
// expected-error@-3 {{'nil' is not compatible with expected argument type 'String'}}
915916

@@ -931,10 +932,12 @@ func valueForKey<K>(_ key: K) -> CacheValue? {
931932
// SR-2242: poor diagnostic when argument label is omitted
932933

933934
func r27212391(x: Int, _ y: Int) {
935+
// expected-note@-1 {{candidate '(Int, Int) -> ()' requires 2 arguments, but 3 were provided}}
934936
let _: Int = x + y
935937
}
936938

937939
func r27212391(a: Int, x: Int, _ y: Int) {
940+
// expected-note@-1 {{incorrect labels for candidate (have: '(a:y:x:)', expected: '(a:x:_:)')}}
938941
let _: Int = a + x + y
939942
}
940943

@@ -946,7 +949,7 @@ r27212391(y: 3, 5) // expected-error {{incorrect argument label in call
946949
r27212391(x: 3, x: 5) // expected-error {{extraneous argument label 'x:' in call}}
947950
r27212391(a: 1, 3, y: 5) // expected-error {{incorrect argument labels in call (have 'a:_:y:', expected 'a:x:_:')}}
948951
r27212391(1, x: 3, y: 5) // expected-error {{incorrect argument labels in call (have '_:x:y:', expected 'a:x:_:')}}
949-
r27212391(a: 1, y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'a:y:x:', expected 'a:x:_:')}} {{17-18=x}} {{23-26=}}
952+
r27212391(a: 1, y: 3, x: 5) // expected-error {{no exact matches in call to global function 'r27212391'}}
950953
r27212391(a: 1, 3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #2}} {{17-17=x: 5, }} {{18-24=}}
951954

952955
// SR-1255

test/Constraints/diagnostics_swift4.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension C_2505 {
2424
class C2_2505: P_2505 {
2525
}
2626

27-
let c_2505 = C_2505(arg: [C2_2505()]) // expected-error {{incorrect argument label in call (have 'arg:', expected 'from:')}}
27+
let c_2505 = C_2505(arg: [C2_2505()]) // expected-error {{extraneous argument label 'arg:' in call}}
2828

2929
// rdar://problem/31898542 - Swift 4: 'type of expression is ambiguous without more context' errors, without a fixit
3030

test/Constraints/rdar42678836.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

33
func foo(chr: Character) -> String {
4-
return String(repeating: String(chr)) // expected-error {{incorrect argument label in call (have 'repeating:', expected 'stringLiteral:')}}
4+
return String(repeating: String(chr)) // expected-error {{missing argument for parameter 'count' in call}} {{39-39=, count: <#Int#>}}
55
}

test/Parse/type_expr.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func genQualifiedType() {
117117

118118
func typeOfShadowing() {
119119
// Try to shadow type(of:)
120-
func type<T>(of t: T.Type, flag: Bool) -> T.Type {
120+
func type<T>(of t: T.Type, flag: Bool) -> T.Type { // expected-note {{'type(of:flag:)' declared here}}
121121
return t
122122
}
123123

@@ -133,8 +133,7 @@ func typeOfShadowing() {
133133
return t
134134
}
135135

136-
// TODO: Errors need improving here.
137-
_ = type(of: Gen<Foo>.Bar) // expected-error{{incorrect argument label in call (have 'of:', expected 'fo:')}}
136+
_ = type(of: Gen<Foo>.Bar) // expected-error{{missing argument for parameter 'flag' in call}} {{28-28=, flag: <#Bool#>}}
138137
_ = type(Gen<Foo>.Bar) // expected-error{{expected member name or constructor call after type name}}
139138
// expected-note@-1{{add arguments after the type to construct a value of the type}}
140139
// expected-note@-2{{use '.self' to reference the type object}}

test/decl/var/property_wrappers.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,8 @@ struct Initialization {
235235
@Wrapper(stored: 17)
236236
var x2: Double
237237

238-
@Wrapper(stored: 17) // expected-error {{initializer expects a single parameter of type 'T' [with T = (wrappedValue: Int, stored: Int)]}}
239-
// expected-note@-1 {{did you mean to pass a tuple?}}
240-
var x3 = 42
238+
@Wrapper(stored: 17)
239+
var x3 = 42 // expected-error {{extra argument 'wrappedValue' in call}}
241240

242241
@Wrapper(stored: 17)
243242
var x4
@@ -720,8 +719,7 @@ struct DefaultedPrivateMemberwiseLets {
720719
func testDefaultedPrivateMemberwiseLets() {
721720
_ = DefaultedPrivateMemberwiseLets()
722721
_ = DefaultedPrivateMemberwiseLets(y: 42)
723-
_ = DefaultedPrivateMemberwiseLets(x: Wrapper(stored: false)) // expected-error{{incorrect argument label in call (have 'x:', expected 'y:')}}
724-
// expected-error@-1 {{cannot convert value of type 'Wrapper<Bool>' to expected argument type 'Int'}}
722+
_ = DefaultedPrivateMemberwiseLets(x: Wrapper(stored: false)) // expected-error{{argument passed to call that takes no arguments}}
725723
}
726724

727725

test/expr/expressions.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,16 @@ func conversionTest(_ a: inout Double, b: inout Int) {
593593
var e3 = Empty(Float(d)) // expected-warning {{variable 'e3' inferred to have type 'Empty', which is an enum with no cases}} expected-note {{add an explicit type annotation to silence this warning}}
594594
}
595595

596-
struct Rule { // expected-note {{'init(target:dependencies:)' declared here}}
596+
struct Rule {
597597
var target: String
598598
var dependencies: String
599599
}
600600

601601
var ruleVar: Rule
602-
ruleVar = Rule("a") // expected-error {{missing argument for parameter 'dependencies' in call}}
602+
// FIXME(diagnostics): To be able to suggest different candidates here we need to teach the solver how to figure out to which parameter
603+
// does argument belong to in this case. If the `target` was of a different type, we currently suggest to add an argument for `dependencies:`
604+
// which is incorrect.
605+
ruleVar = Rule("a") // expected-error {{cannot convert value of type 'String' to expected argument type '(target: String, dependencies: String)'}}
603606

604607

605608
class C {

test/expr/postfix/dot/init_ref_delegation.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class Z0 {
6767
init() { // expected-error {{designated initializer for 'Z0' cannot delegate (with 'self.init'); did you mean this to be a convenience initializer?}} {{3-3=convenience }}
6868
// expected-note @+2 {{delegation occurs here}}
6969

70-
self.init(5, 5) // expected-error{{cannot invoke 'Z0.init' with an argument list of type '(Int, Int)'}}
71-
// expected-note @-1 {{overloads for 'Z0.init' exist with these partially matching parameter lists: (), (value: Double), (value: Int)}}
70+
self.init(5, 5) // expected-error{{extra argument in call}}
7271
}
7372

7473
init(value: Int) { /* ... */ }
@@ -77,8 +76,7 @@ class Z0 {
7776

7877
struct Z1 {
7978
init() {
80-
self.init(5, 5) // expected-error{{cannot invoke 'Z1.init' with an argument list of type '(Int, Int)'}}
81-
// expected-note @-1 {{overloads for 'Z1.init' exist with these partially matching parameter lists: (), (value: Double), (value: Int)}}
79+
self.init(5, 5) // expected-error{{extra argument in call}}
8280
}
8381

8482
init(value: Int) { /* ... */ }
@@ -90,8 +88,7 @@ enum Z2 {
9088
case B
9189

9290
init() {
93-
self.init(5, 5) // expected-error{{cannot invoke 'Z2.init' with an argument list of type '(Int, Int)'}}
94-
// expected-note @-1 {{overloads for 'Z2.init' exist with these partially matching parameter lists: (), (value: Double), (value: Int)}}
91+
self.init(5, 5) // expected-error{{extra argument in call}}
9592
}
9693

9794
init(value: Int) { /* ... */ }
@@ -323,8 +320,7 @@ func foo<T: C>(_ x: T, y: T.Type) where T: P {
323320

324321
class TestOverloadSets {
325322
convenience init() {
326-
self.init(5, 5) // expected-error{{cannot invoke 'TestOverloadSets.init' with an argument list of type '(Int, Int)'}}
327-
// expected-note @-1 {{overloads for 'TestOverloadSets.init' exist with these partially matching parameter lists: (), (a: Z0), (value: Double), (value: Int)}}
323+
self.init(5, 5) // expected-error{{extra argument in call}}
328324
}
329325

330326
convenience init(a : Z0) {

test/expr/unary/keypath/keypath.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,10 @@ func testLabeledSubscript() {
504504
let k = \AA.[labeled: 0]
505505

506506
// TODO: These ought to work without errors.
507-
let _ = \AA.[keyPath: k] // expected-error {{incorrect argument label in call (have 'keyPath:', expected 'labeled:')}}
507+
let _ = \AA.[keyPath: k] // expected-error {{extraneous argument label 'keyPath:' in call}}
508508
// expected-error@-1 {{cannot convert value of type 'KeyPath<AA, Int>' to expected argument type 'Int'}}
509509

510-
let _ = \AA.[keyPath: \AA.[labeled: 0]] // expected-error {{incorrect argument label in call (have 'keyPath:', expected 'labeled:')}}
510+
let _ = \AA.[keyPath: \AA.[labeled: 0]] // expected-error {{extraneous argument label 'keyPath:' in call}}
511511
// expected-error@-1 {{cannot convert value of type 'KeyPath<AA, Int>' to expected argument type 'Int'}}
512512
}
513513

test/stmt/errors.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ func nine() throws {
117117
try nine_helper(y: 0) // expected-error {{missing argument for parameter #1 in call}}
118118
}
119119
func ten_helper(_ x: Int) {}
120-
func ten_helper(_ x: Int, y: Int) throws {}
120+
func ten_helper(_ x: Int, y: Int) throws {} // expected-note {{'ten_helper(_:y:)' declared here}}
121121
func ten() throws {
122-
try ten_helper(y: 0) // expected-error {{extraneous argument label 'y:' in call}} {{18-21=}}
122+
try ten_helper(y: 0) // expected-error {{missing argument for parameter #1 in call}} {{18-18=<#Int#>, }}
123123
}
124124

125125
// rdar://21074857

0 commit comments

Comments
 (0)