Skip to content

Commit 38306a9

Browse files
[test] Adjusting test cases for ambiguos candidates
1 parent 940ffdf commit 38306a9

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,13 +3009,14 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
30093009
}
30103010
}
30113011

3012+
// If any of the non-overloaded common fixes appear in all solutions
3013+
// and can be diagnosed by the diagnoseForAmbiguity implementation,
3014+
// we diagnose and be done.
30123015
if (diagnosed)
30133016
return true;
30143017

3015-
// If all non-overloaded common fixes do not appear in all solutions
3016-
// nor are diagnosed for ambiguity, let's try to fall back to common
3017-
// anchor diagnostic.
3018-
3018+
// Otherwise let's try to fall back to overload common anchor
3019+
// diagnostic if possible.
30193020
if (ambiguosOverloads.empty())
30203021
return false;
30213022

test/Constraints/diagnostics.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,8 @@ enum Color {
496496

497497
static func rainbow() -> Color {}
498498

499-
static func overload(a : Int) -> Color {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(a:)')}}
500-
// expected-note@-1 {{candidate has partially matching parameter list (a: Int)}}
501-
static func overload(b : Int) -> Color {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(b:)')}}
502-
// expected-note@-1 {{candidate has partially matching parameter list (b: Int)}}
499+
static func overload(a : Int) -> Color {} // expected-note 2 {{incorrect labels for candidate (have: '(_:)', expected: '(a:)')}}
500+
static func overload(b : Int) -> Color {} // expected-note 2 {{incorrect labels for candidate (have: '(_:)', expected: '(b:)')}}
503501

504502
static func frob(_ a : Int, b : inout Int) -> Color {}
505503
static var svar: Color { return .Red }

test/Constraints/super_constructor.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ class B {
3939
init() {
4040
}
4141

42-
init(x:Int) { // expected-note{{candidate has partially matching parameter list (x: Int)}}
42+
init(x:Int) { // expected-note{{incorrect labels for candidate (have: '(_:)', expected: '(x:)')}}
4343
}
4444

45-
init(a:UnicodeScalar) { // expected-note {{candidate has partially matching parameter list (a: UnicodeScalar)}}
45+
init(a:UnicodeScalar) { // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(a:)')}}
4646
}
47-
init(b:UnicodeScalar) { // expected-note{{candidate has partially matching parameter list (b: UnicodeScalar)}}
47+
init(b:UnicodeScalar) { // expected-note{{incorrect labels for candidate (have: '(_:)', expected: '(b:)')}}
4848
}
4949

50-
init(z:Float) { // expected-note{{candidate has partially matching parameter list (z: Float)}}
50+
init(z:Float) { // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(z:)')}}
5151
super.init() // expected-error{{'super' members cannot be referenced in a root class}}
5252
}
5353
}

test/expr/postfix/dot/init_ref_delegation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ class TestOverloadSets {
323323
self.init(5, 5) // expected-error{{extra argument in call}}
324324
}
325325

326-
convenience init(a : Z0) { // expected-note{{candidate has partially matching parameter list (a: Z0)}}
326+
convenience init(a : Z0) { // expected-note{{incorrect labels for candidate (have: '(_:)', expected: '(a:)')}}
327327
self.init(42 as Int8) // expected-error{{no exact matches in call to initializer}}
328328
}
329329

330-
init(value: Int) { /* ... */ } // expected-note{{candidate has partially matching parameter list (value: Int)}}
331-
init(value: Double) { /* ... */ } // expected-note{{candidate has partially matching parameter list (value: Double)}}
330+
init(value: Int) { /* ... */ } // expected-note{{incorrect labels for candidate (have: '(_:)', expected: '(value:)')}}
331+
init(value: Double) { /* ... */ } // expected-note{{incorrect labels for candidate (have: '(_:)', expected: '(value:)')}}
332332
}
333333

334334
class TestNestedExpr {

0 commit comments

Comments
 (0)