|
1 | 1 | // RUN: %target-typecheck-verify-swift
|
2 | 2 |
|
3 |
| -// XFAIL: noncopyable_generics |
4 |
| - |
5 | 3 | // This test focuses on the prevention of users from _writing_ types where
|
6 | 4 | // a move-only type is substituted for a generic parameter.
|
7 | 5 | //
|
@@ -52,30 +50,30 @@ struct CerebralValley<T> {
|
52 | 50 | func basic_vararg(_ va: MO...) {} // expected-error {{noncopyable type 'MO' cannot be used within a variadic type yet}}
|
53 | 51 |
|
54 | 52 | func illegalTypes<T>(_ t: T) {
|
55 |
| - let _: Array<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}} |
56 |
| - let _: Maybe<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Maybe<T>' yet}} |
57 |
| - let _: Dictionary<MO, String> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}} |
58 |
| - let _: [MO] // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}} |
59 |
| - let _: [String : MO] // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}} |
60 |
| - let _: [MO : MO] // expected-error 2{{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}} |
61 |
| - let _: [MO : T] // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}} |
62 |
| - |
63 |
| - _ = t as! ValBox<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'ValBox<T>' yet}} |
64 |
| - |
65 |
| - let _: Optional<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}} |
66 |
| - let _: MO? // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}} |
67 |
| - let _: MO?? // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}} |
68 |
| - let _: MO! // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}} |
69 |
| - let _: MO?! // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}} |
| 53 | + let _: Array<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 54 | + let _: Maybe<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 55 | + let _: Dictionary<MO, String> // expected-error {{type 'MO' does not conform to protocol 'Hashable'}} |
| 56 | + let _: [MO] // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 57 | + let _: [String : MO] // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 58 | + let _: [MO : MO] // expected-error {{type 'MO' does not conform to protocol 'Hashable'}} |
| 59 | + let _: [MO : T] // expected-error {{type 'MO' does not conform to protocol 'Hashable'}} |
| 60 | + |
| 61 | + _ = t as! ValBox<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 62 | + |
| 63 | + let _: Optional<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 64 | + let _: MO? // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 65 | + let _: MO?? // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 66 | + let _: MO! // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 67 | + let _: MO?! // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
70 | 68 |
|
71 | 69 | let _: Klass & MO // expected-error {{non-protocol, non-class type 'MO' cannot be used within a protocol-constrained type}}
|
72 | 70 | let _: any MO // expected-error {{'any' has no effect on concrete type 'MO'}}
|
73 | 71 | let _: any GenericMO<T> // expected-error {{'any' has no effect on concrete type 'GenericMO<T>'}}
|
74 | 72 |
|
75 |
| - let _: CerebralValley<MO>.TechBro // expected-error {{noncopyable type 'MO' cannot be used with generic type 'CerebralValley<T>' yet}} |
76 |
| - let _: CerebralValley<Int>.GenericBro<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'CerebralValley<T>.GenericBro<U>' yet}} |
| 73 | + let _: CerebralValley<MO>.TechBro // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
| 74 | + let _: CerebralValley<Int>.GenericBro<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
77 | 75 |
|
78 |
| - let _: GenericMO<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'GenericMO<T>' yet}} |
| 76 | + let _: GenericMO<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}} |
79 | 77 | }
|
80 | 78 |
|
81 | 79 | func illegalInExpr() {
|
|
0 commit comments