Skip to content

Commit c09af51

Browse files
[tests] Adjusting regression tests argument mismatch diagnostics on suit
1 parent 12c8630 commit c09af51

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

test/Constraints/fixes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,5 @@ func testKeyPathSubscriptArgFixes(_ fn: @escaping () -> Int) {
358358

359359
func sr12426(a: Any, _ str: String?) {
360360
a == str // expected-error {{binary operator '==' cannot be applied to operands of type 'Any' and 'String?'}}
361-
// expected-note@-1 {{overloads for '==' exist with these partially matching parameter lists: (String, String)}}
361+
// expected-note@-1 {{overloads for '==' exist with these partially matching parameter lists: (CodingUserInfoKey, CodingUserInfoKey), (String, String)}}
362362
}

test/Constraints/optional.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ func test_force_unwrap_not_being_too_eager() {
423423

424424
// rdar://problem/57097401
425425
func invalidOptionalChaining(a: Any) {
426-
a == "="? // expected-error {{cannot use optional chaining on non-optional value of type 'String'}}
427-
// expected-error@-1 {{cannot convert value of type 'Any' to expected argument type 'Any.Type?'}}
426+
a == "="? // expected-error {{binary operator '==' cannot be applied to operands of type 'Any' and 'String?'}}
427+
// expected-note@-1 {{overloads for '==' exist with these partially matching parameter lists: (CodingUserInfoKey, CodingUserInfoKey), (FloatingPointSign, FloatingPointSign), (String, String), (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass)}}
428428
}
429429

430430
// SR-12309 - Force unwrapping 'nil' compiles without warning

test/Parse/operators.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ postfix func ^ (x: Man) -> () -> God {
8888
return { return God() }
8989
}
9090

91-
// TODO(diagnostics): This is ambiguous operator use because if solver attempted postfix version of the operator `^`
92-
// it could have found a solution, with infix one nothing matches - neither argument nor contextual type. It should
93-
// be possible to find a way to diagnose operator use here instead of type ambiguity...
94-
var _ : God = Man()^() // expected-error{{type of expression is ambiguous without more context}}
91+
var _ : God = Man()^() // expected-error{{cannot convert value of type 'Man' to expected argument type 'TheDevil'}}
92+
// expected-error@-1 {{cannot convert value of type '()' to expected argument type 'God'}}
93+
// expected-error@-2 {{cannot convert value of type 'Man' to specified type 'God'}}
9594

9695
func &(x : Man, y : Man) -> Man { return x } // forgive amp_prefix token
9796

test/Parse/type_expr.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ protocol P3 {}
266266
func compositionType() {
267267
_ = P1 & P2 // expected-error {{expected member name or constructor call after type name}} expected-note{{use '.self'}} {{7-7=(}} {{14-14=).self}}
268268
_ = P1 & P2.self // expected-error {{binary operator '&' cannot be applied to operands of type 'P1.Protocol' and 'P2.Protocol'}}
269+
// expected-note@-1 {{overloads for '&' exist with these partially matching parameter lists: (Int, Int), (Int16, Int16), (Int32, Int32), (Int64, Int64), (Int8, Int8), (UInt, UInt), (UInt16, UInt16), (UInt32, UInt32), (UInt64, UInt64), (UInt8, UInt8)}}
269270
_ = (P1 & P2).self // Ok.
270271
_ = (P1 & (P2)).self // FIXME: OK? while `typealias P = P1 & (P2)` is rejected.
271272
_ = (P1 & (P2, P3)).self // expected-error {{non-protocol, non-class type '(P2, P3)' cannot be used within a protocol-constrained type}}

test/stdlib/UnicodeScalarDiagnostics.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ func isString(_ s: inout String) {}
88
func test_UnicodeScalarDoesNotImplementArithmetic(_ us: UnicodeScalar, i: Int) {
99
var a1 = "a" + "b" // OK
1010
isString(&a1)
11-
let a2 = "a" - "b" // expected-error {{binary operator '-' cannot be applied to two 'String' operands}} expected-note {{}}
12-
let a3 = "a" * "b" // expected-error {{binary operator '*' cannot be applied to two 'String' operands}} expected-note {{}}
13-
let a4 = "a" / "b" // expected-error {{binary operator '/' cannot be applied to two 'String' operands}} expected-note {{}}
11+
let a2 = "a" - "b" // expected-error {{binary operator '-' cannot be applied to two 'String' operands}}
12+
// expected-note@-1 {{overloads for '-' exist with these partially matching parameter lists: (Double, Double), (Float, Float), (Float16, Float16), (Float80, Float80), (Int, Int), (Int16, Int16), (Int32, Int32), (Int64, Int64), (Int8, Int8), (UInt, UInt), (UInt16, UInt16), (UInt32, UInt32), (UInt64, UInt64), (UInt8, UInt8)}}
13+
let a3 = "a" * "b" // expected-error {{binary operator '*' cannot be applied to two 'String' operands}}
14+
// expected-note@-1 {{overloads for '*' exist with these partially matching parameter lists: (Double, Double), (Float, Float), (Float16, Float16), (Float80, Float80), (Int, Int), (Int16, Int16), (Int32, Int32), (Int64, Int64), (Int8, Int8), (UInt, UInt), (UInt16, UInt16), (UInt32, UInt32), (UInt64, UInt64), (UInt8, UInt8)}}
15+
let a4 = "a" / "b" // expected-error {{binary operator '/' cannot be applied to two 'String' operands}}
16+
// expected-note@-1 {{overloads for '/' exist with these partially matching parameter lists: (Double, Double), (Float, Float), (Float16, Float16), (Float80, Float80), (Int, Int), (Int16, Int16), (Int32, Int32), (Int64, Int64), (Int8, Int8), (UInt, UInt), (UInt16, UInt16), (UInt32, UInt32), (UInt64, UInt64), (UInt8, UInt8)}}
1417

1518
let b1 = us + us // expected-error {{binary operator '+' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}
1619
let b2 = us - us // expected-error {{binary operator '-' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}

0 commit comments

Comments
 (0)