|
3 | 3 | // Because of -enable-experimental-feature TupleConformances
|
4 | 4 | // REQUIRES: asserts
|
5 | 5 |
|
| 6 | +extension () { |
| 7 | + // expected-error@-1 {{tuple extension must be written as extension of '(repeat each Element)'}} |
| 8 | + // expected-error@-2 {{tuple extension must declare conformance to exactly one protocol}} |
| 9 | +} |
| 10 | + |
| 11 | +typealias Tuple<each Element> = (repeat each Element) |
| 12 | + |
| 13 | +protocol Q {} |
| 14 | + |
| 15 | +class C {} |
| 16 | + |
| 17 | +extension Tuple: Q where repeat each Element: Collection, repeat (each Element).Element == (each Element).Index, repeat (each Element).Indices: AnyObject, repeat (each Element).SubSequence: C {} |
| 18 | +// expected-error@-1 {{tuple extension must require that 'each Element' conforms to 'Q'}} |
| 19 | +// expected-error@-2 {{tuple extension cannot require that 'each Element' conforms to 'Collection'}} |
| 20 | +// expected-error@-3 {{tuple extension cannot require that '(each Element).Element' is the same type as '(each Element).Index'}} |
| 21 | +// expected-error@-4 {{tuple extension cannot require that '(each Element).Indices' conforms to 'AnyObject'}} |
| 22 | +// expected-error@-5 {{tuple extension cannot require that '(each Element).SubSequence' subclasses 'C'}} |
| 23 | + |
| 24 | +protocol Base1 {} |
| 25 | +protocol Derived1: Base1 {} |
| 26 | + |
| 27 | +extension Tuple: Derived1 where repeat each Element: Derived1 {} |
| 28 | +// expected-error@-1 {{conditional conformance of type '(repeat each Element)' to protocol 'Derived1' does not imply conformance to inherited protocol 'Base1'}} // FIXME: crappy error |
| 29 | +// expected-note@-2 {{did you mean to explicitly state the conformance like 'extension (repeat each Element): Base1 where ...'?}} |
| 30 | +// expected-error@-3 {{tuple extension must declare conformance to exactly one protocol}} |
| 31 | + |
| 32 | +protocol Base2 {} |
| 33 | +protocol Derived2: Base2 {} |
| 34 | + |
| 35 | +extension Tuple: Derived2 {} |
| 36 | +// expected-error@-1 {{tuple extension must declare conformance to exactly one protocol}} // FIXME: crappy error |
| 37 | + |
6 | 38 | protocol P {
|
7 | 39 | associatedtype A
|
8 | 40 | associatedtype B
|
9 | 41 |
|
10 | 42 | func f()
|
11 | 43 | }
|
12 | 44 |
|
13 |
| -extension () {} |
14 |
| -// expected-error@-1 {{tuple extension must be written as extension of '(repeat each Element)'}} |
15 |
| -// FIXME: Inaccurate |
16 |
| - |
17 |
| -typealias Tuple<each Element> = (repeat each Element) |
18 |
| - |
19 | 45 | extension Tuple: P where repeat each Element: P {
|
20 | 46 | typealias A = (repeat (each Element).A)
|
21 | 47 | typealias B = Float
|
|
0 commit comments