|
1 |
| -// FIXME(integers): confusing diagnostics when new integer protocols are |
2 |
| -// implemented. <rdar://problem/29912193> |
3 |
| -// XFAIL: * |
4 |
| - |
5 | 1 | // RUN: %target-typecheck-verify-swift
|
6 | 2 |
|
| 3 | +// FIXME: The clarity of these diagnostics could be improved. |
| 4 | +// <rdar://problem/29912193> |
| 5 | + |
7 | 6 | func isString(_ s: inout String) {}
|
8 | 7 |
|
9 | 8 | func test_UnicodeScalarDoesNotImplementArithmetic(_ us: UnicodeScalar, i: Int) {
|
10 | 9 | var a1 = "a" + "b" // OK
|
11 | 10 | isString(&a1)
|
12 | 11 | let a2 = "a" - "b" // expected-error {{binary operator '-' cannot be applied to two 'String' operands}}
|
13 |
| - // expected-note @-1 {{overloads for '-' exist with these partially matching parameter lists:}} |
14 | 12 | let a3 = "a" * "b" // expected-error {{binary operator '*' cannot be applied to two 'String' operands}}
|
15 |
| - // expected-note @-1 {{overloads for '*' exist with these partially matching parameter lists:}} |
16 | 13 | let a4 = "a" / "b" // expected-error {{binary operator '/' cannot be applied to two 'String' operands}}
|
17 |
| - // expected-note @-1 {{overloads for '/' exist with these partially matching parameter lists:}} |
18 | 14 |
|
19 |
| - let b1 = us + us // expected-error {{binary operator '+' cannot be applied to two 'UnicodeScalar' operands}} |
20 |
| - // expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists:}} |
21 |
| - let b2 = us - us // expected-error {{binary operator '-' cannot be applied to two 'UnicodeScalar' operands}} |
22 |
| - // expected-note @-1 {{overloads for '-' exist with these partially matching parameter lists:}} |
23 |
| - let b3 = us * us // expected-error {{binary operator '*' cannot be applied to two 'UnicodeScalar' operands}} |
24 |
| - // expected-note @-1 {{overloads for '*' exist with these partially matching parameter lists:}} |
25 |
| - let b4 = us / us // expected-error {{binary operator '/' cannot be applied to two 'UnicodeScalar' operands}} |
26 |
| - // expected-note @-1 {{overloads for '/' exist with these partially matching parameter lists:}} |
| 15 | + let b1 = us + us // expected-error {{referencing operator function '+' on 'RangeReplaceableCollection' requires that 'UnicodeScalar' (aka 'Unicode.Scalar') conform to 'RangeReplaceableCollection'}} |
| 16 | + let b2 = us - us // expected-error {{referencing operator function '-' on 'FloatingPoint' requires that 'UnicodeScalar' (aka 'Unicode.Scalar') conform to 'FloatingPoint'}} |
| 17 | + let b3 = us * us // expected-error {{referencing operator function '*' on 'FloatingPoint' requires that 'UnicodeScalar' (aka 'Unicode.Scalar') conform to 'FloatingPoint'}} |
| 18 | + let b4 = us / us // expected-error {{referencing operator function '/' on 'FloatingPoint' requires that 'UnicodeScalar' (aka 'Unicode.Scalar') conform to 'FloatingPoint'}} |
27 | 19 |
|
28 |
| - let c1 = us + i // expected-error {{binary operator '+' cannot be applied to operands of type 'UnicodeScalar' and 'Int'}} expected-note{{overloads for '+' exist with these partially matching parameter lists:}} |
29 |
| - let c2 = us - i // expected-error {{binary operator '-' cannot be applied to operands of type 'UnicodeScalar' and 'Int'}} expected-note{{overloads for '-' exist with these partially matching parameter lists: (UnsafeMutablePointer<Pointee>, Int), (UnsafePointer<Pointee>, Int)}} |
30 |
| - let c3 = us * i // expected-error {{binary operator '*' cannot be applied to operands of type 'UnicodeScalar' and 'Int'}} expected-note {{expected an argument list of type '(Int, Int)'}} |
31 |
| - let c4 = us / i // expected-error {{binary operator '/' cannot be applied to operands of type 'UnicodeScalar' and 'Int'}} expected-note {{expected an argument list of type '(Int, Int)'}} |
| 20 | + let c1 = us + i // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
| 21 | + let c2 = us - i // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
| 22 | + let c3 = us * i // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
| 23 | + let c4 = us / i // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
32 | 24 |
|
33 |
| - let d1 = i + us // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UnicodeScalar'}} expected-note{{overloads for '+' exist with these partially matching parameter lists:}} |
34 |
| - let d2 = i - us // expected-error {{binary operator '-' cannot be applied to operands of type 'Int' and 'UnicodeScalar'}} expected-note {{expected an argument list of type '(Int, Int)'}} |
35 |
| - let d3 = i * us // expected-error {{binary operator '*' cannot be applied to operands of type 'Int' and 'UnicodeScalar'}} expected-note {{expected an argument list of type '(Int, Int)'}} |
36 |
| - let d4 = i / us // expected-error {{binary operator '/' cannot be applied to operands of type 'Int' and 'UnicodeScalar'}} expected-note {{expected an argument list of type '(Int, Int)'}} |
| 25 | + let d1 = i + us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
| 26 | + let d2 = i - us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
| 27 | + let d3 = i * us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
| 28 | + let d4 = i / us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}} |
37 | 29 | }
|
38 | 30 |
|
0 commit comments