Skip to content

Commit 84cd99a

Browse files
committed
[Diagnostics] Enable extraneous/incorrect label diagnostics via solver fixes
This builds on initial commit which added `RelabelArguments` fix to the solver that only supported `missingLabels` at that moment, but now it supports all three posibilities - missing/extraneous and incorrect labels.
1 parent dfad872 commit 84cd99a

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,14 @@ class ArgumentFailureTracker : public MatchCallArgumentListener {
713713
return !CS.shouldAttemptFixes();
714714
}
715715

716+
bool extraneousLabel(unsigned paramIndex) override {
717+
return !CS.shouldAttemptFixes();
718+
}
719+
720+
bool incorrectLabel(unsigned paramIndex) override {
721+
return !CS.shouldAttemptFixes();
722+
}
723+
716724
bool relabelArguments(ArrayRef<Identifier> newLabels) override {
717725
if (!CS.shouldAttemptFixes())
718726
return true;

test/ClangImporter/objc_factory_method.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ func testInstanceTypeFactoryMethodInherited() {
2222
_ = NSObjectFactorySub() // okay, prefers init method
2323
_ = NSObjectFactorySub(integer: 1)
2424
_ = NSObjectFactorySub(double: 314159)
25-
_ = NSObjectFactorySub(float: 314159) // expected-error{{argument labels '(float:)' do not match any available overloads}}
26-
// expected-note @-1 {{overloads for 'NSObjectFactorySub' exist with these partially matching parameter lists: (integer: Int), (double: Double)}}
25+
_ = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}}
2726
let a = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{argument labels '(buildingWidgets:)' do not match any available overloads}}
2827
// expected-note @-1 {{overloads for 'NSObjectFactorySub' exist with these partially matching parameter lists: (integer: Int), (double: Double)}}
2928
_ = a

test/ClangImporter/objc_implicit_with.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func testInstanceTypeFactoryMethodInherited() {
3333
_ = NSObjectFactorySub() // okay, prefers init method
3434
_ = NSObjectFactorySub(integer: 1)
3535
_ = NSObjectFactorySub(double: 314159)
36-
_ = NSObjectFactorySub(float: 314159) // expected-error{{argument labels '(float:)' do not match any available overloads}}
37-
// expected-note @-1 {{overloads for 'NSObjectFactorySub' exist with these partially matching parameter lists: (integer: Int), (double: Double)}}
36+
_ = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}}
3837
let a = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{argument labels '(buildingWidgets:)' do not match any available overloads}}
3938
// expected-note @-1 {{overloads for 'NSObjectFactorySub' exist with these partially matching parameter lists: (integer: Int), (double: Double)}}
4039
_ = a

test/Constraints/diagnostics_swift4.swift

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

27-
let c_2505 = C_2505(arg: [C2_2505()]) // expected-error {{argument labels '(arg:)' do not match any available overloads}}
28-
// expected-note@-1 {{overloads for 'C_2505' exist with these partially matching parameter lists: (Any), (from: [T])}}
27+
let c_2505 = C_2505(arg: [C2_2505()]) // expected-error {{incorrect argument label in call (have 'arg:', expected 'from:')}}
2928

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

test/Constraints/dynamic_lookup.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,5 @@ func testOverloadedWithUnavailable(ao: AnyObject) {
338338

339339
func dynamicInitCrash(ao: AnyObject.Type) {
340340
let sdk = ao.init(blahblah: ())
341-
// expected-error@-1 {{argument labels '(blahblah:)' do not match any available overloads}}
342-
// expected-note@-2 {{overloads for 'AnyObject.Type.init' exist with these partially matching parameter lists}}
341+
// expected-error@-1 {{incorrect argument label in call (have 'blahblah:', expected 'toMemory:')}}
343342
}

test/Constraints/keyword_arguments.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ struct X1 {
88
init(_ a: Int) { }
99
func f1(_ a: Int) {}
1010
}
11-
X1(a: 5).f1(b: 5) // expected-error{{extraneous argument label 'a:' in call}}{{4-7=}}
11+
X1(a: 5).f1(b: 5)
12+
// expected-error@-1 {{extraneous argument label 'a:' in call}} {{4-7=}}
13+
// expected-error@-2 {{extraneous argument label 'b:' in call}} {{13-16=}}
1214

1315
// <rdar://problem/16801056>
1416
enum Policy {

test/Constraints/optional.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func sr2752(x: String?, y: String?) {
209209
var sr3248 : ((Int) -> ())!
210210
sr3248?(a: 2) // expected-error {{extraneous argument label 'a:' in call}}
211211
sr3248!(a: 2) // expected-error {{extraneous argument label 'a:' in call}}
212-
sr3248(a: 2) // expected-error {{cannot call value of non-function type '((Int) -> ())?'}}
212+
sr3248(a: 2) // expected-error {{extraneous argument label 'a:' in call}}
213213

214214
struct SR_3248 {
215215
var callback: (([AnyObject]) -> Void)!

test/decl/inherit/initializer.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ class NotInherited1 : D {
5858

5959
func testNotInherited1() {
6060
var n1 = NotInherited1(int: 5)
61-
var n2 = NotInherited1(double: 2.71828) // expected-error{{argument labels '(double:)' do not match any available overloads}}
62-
// expected-note @-1 {{overloads for 'NotInherited1' exist with these partially matching parameter lists: (int: Int), (float: Float)}}
61+
var n2 = NotInherited1(double: 2.71828) // expected-error{{incorrect argument label in call (have 'double:', expected 'float:')}}
6362
}
6463

6564
class NotInherited1Sub : NotInherited1 {
@@ -71,8 +70,7 @@ class NotInherited1Sub : NotInherited1 {
7170
func testNotInherited1Sub() {
7271
var n1 = NotInherited1Sub(int: 5)
7372
var n2 = NotInherited1Sub(float: 3.14159)
74-
var n3 = NotInherited1Sub(double: 2.71828) // expected-error{{argument labels '(double:)' do not match any available overloads}}
75-
// expected-note @-1 {{overloads for 'NotInherited1Sub' exist with these partially matching parameter lists: (int: Int), (float: Float)}}
73+
var n3 = NotInherited1Sub(double: 2.71828) // expected-error{{incorrect argument label in call (have 'double:', expected 'float:')}}
7674
}
7775

7876
// Having a stored property without an initial value prevents

test/expr/postfix/dot/init_ref_delegation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ func foo<T: C>(_ x: T, y: T.Type) where T: P {
294294
var cs2 = T.init(x: 0) // expected-error{{'required' initializer}}
295295
var cs3 = T.init() // expected-error{{'required' initializer}}
296296
var cs4 = T.init(proto: "")
297-
var cs5 = T.init(notfound: "") // expected-error{{argument labels '(notfound:)' do not match any available overloads}}
298-
// expected-note @-1 {{overloads for 'T.Type.init' exist with these partially matching parameter lists: (x: Int), (required: Double), (proto: String)}}
297+
var cs5 = T.init(notfound: "") // expected-error{{incorrect argument label in call (have 'notfound:', expected 'proto:')}}
299298

300299
var csf1: (Double) -> T = T.init
301300
var csf2: (Int) -> T = T.init // expected-error{{'required' initializer}}

validation-test/stdlib/FixedPointDiagnostics.swift.gyb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,19 @@ func test_truncatingBitPatternAPIIsStableAcrossPlatforms() {
3535
_ = UInt8(truncatingBitPattern: UInt(0))
3636
_ = UInt16(truncatingBitPattern: UInt(0))
3737
_ = UInt32(truncatingBitPattern: UInt(0))
38-
UInt64(truncatingBitPattern: UInt(0)) // expected-error {{argument labels '(truncatingBitPattern:)' do not match any available overloads}}
39-
// expected-note @-1 {{overloads for 'UInt64' exist with these partially matching parameter lists}}
38+
UInt64(truncatingBitPattern: UInt(0)) // expected-error {{extraneous argument label 'truncatingBitPattern:' in call}}
4039
UInt(truncatingBitPattern: UInt(0)) // expected-error {{}} expected-note * {{}}
4140

4241
_ = Int8(truncatingBitPattern: UInt(0))
4342
_ = Int16(truncatingBitPattern: UInt(0))
4443
_ = Int32(truncatingBitPattern: UInt(0))
45-
Int64(truncatingBitPattern: UInt(0)) // expected-error {{argument labels '(truncatingBitPattern:)' do not match any available overloads}}
46-
// expected-note @-1 {{overloads for 'Int64' exist with}}
44+
Int64(truncatingBitPattern: UInt(0)) // expected-error {{extraneous argument label 'truncatingBitPattern:' in call}}
4745
Int(truncatingBitPattern: UInt(0)) // expected-error {{}} expected-note * {{}}
4846

4947
_ = UInt8(truncatingBitPattern: Int(0))
5048
_ = UInt16(truncatingBitPattern: Int(0))
5149
_ = UInt32(truncatingBitPattern: Int(0))
52-
UInt64(truncatingBitPattern: Int(0)) // expected-error {{argument labels '(truncatingBitPattern:)' do not match any available overloads}}
53-
// expected-note @-1 {{overloads for 'UInt64' exist with these partially matching parameter lists}}
50+
UInt64(truncatingBitPattern: Int(0)) // expected-error {{extraneous argument label 'truncatingBitPattern:' in call}}
5451
UInt(truncatingBitPattern: Int(0)) // expected-error {{}} expected-note * {{}}
5552

5653
_ = Int8(truncatingBitPattern: Int(0))

0 commit comments

Comments
 (0)