4
4
5
5
class CopyableKlass { }
6
6
7
- @_moveOnly
8
- class MoveOnlyKlass {
7
+ class MoveOnlyKlass : ~ Copyable {
9
8
init ? ( ) { } // expected-error {{move-only types cannot have failable initializers yet}}
10
9
}
11
10
12
- @_moveOnly
13
- class MoveOnlyStruct {
11
+ class MoveOnlyStruct : ~ Copyable {
14
12
init ? ( one: Bool ) { } // expected-error {{move-only types cannot have failable initializers yet}}
15
13
init !( two: Bool ) { } // expected-error {{move-only types cannot have failable initializers yet}}
16
14
}
@@ -21,8 +19,7 @@ class C {
21
19
var moveOnlyS : MoveOnlyStruct ? = nil // expected-error {{move-only type 'MoveOnlyStruct' cannot be used with generics yet}}
22
20
}
23
21
24
- @_moveOnly
25
- class CMoveOnly {
22
+ class CMoveOnly : ~ Copyable {
26
23
var copyable : CopyableKlass ? = nil
27
24
var moveOnlyC : MoveOnlyKlass ? = nil // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
28
25
var moveOnlyS : MoveOnlyStruct ? = nil // expected-error {{move-only type 'MoveOnlyStruct' cannot be used with generics yet}}
@@ -47,11 +44,10 @@ struct S { // expected-error {{struct 'S' cannot contain a move-only type withou
47
44
var moveOnly2 : MoveOnlyStruct ? // expected-error {{move-only type 'MoveOnlyStruct' cannot be used with generics yet}}
48
45
var moveOnly : MoveOnlyStruct // expected-note {{contained move-only property 'S.moveOnly'}}
49
46
var moveOnly3 : OptionalGrandField < MoveOnlyKlass > // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
50
- var moveOnly3 : OptionalGrandField < MoveOnlyStruct > // expected-error {{move-only type 'MoveOnlyStruct' cannot be used with generics yet}}
47
+ var moveOnly4 : OptionalGrandField < MoveOnlyStruct > // expected-error {{move-only type 'MoveOnlyStruct' cannot be used with generics yet}}
51
48
}
52
49
53
- @_moveOnly
54
- struct SMoveOnly {
50
+ struct SMoveOnly : ~ Copyable {
55
51
var copyable : CopyableKlass
56
52
var moveOnly : MoveOnlyKlass
57
53
}
@@ -62,8 +58,7 @@ enum E { // expected-error {{enum 'E' cannot contain a move-only type without al
62
58
case rhs2( OptionalGrandField < MoveOnlyKlass > ) // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
63
59
}
64
60
65
- @_moveOnly
66
- enum EMoveOnly {
61
+ enum EMoveOnly : ~ Copyable {
67
62
case lhs( CopyableKlass )
68
63
case rhs( MoveOnlyKlass )
69
64
@@ -84,8 +79,7 @@ func foo() {
84
79
var moveOnly : MoveOnlyKlass ? = nil // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
85
80
}
86
81
87
- @_moveOnly
88
- class C2MoveOnly {
82
+ class C2MoveOnly : ~ Copyable {
89
83
var copyable : CopyableKlass ? = nil
90
84
var moveOnly : MoveOnlyKlass ? = nil // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
91
85
}
@@ -95,8 +89,7 @@ func foo() {
95
89
var moveOnly : MoveOnlyKlass // expected-note {{contained move-only property 'S2.moveOnly'}}
96
90
}
97
91
98
- @_moveOnly
99
- struct S2MoveOnly {
92
+ struct S2MoveOnly : ~ Copyable {
100
93
var copyable : CopyableKlass
101
94
var moveOnly : MoveOnlyKlass
102
95
}
@@ -106,8 +99,7 @@ func foo() {
106
99
case rhs( MoveOnlyKlass ) // expected-note {{contained move-only enum case 'E2.rhs'}}
107
100
}
108
101
109
- @_moveOnly
110
- enum E2MoveOnly {
102
+ enum E2MoveOnly : ~ Copyable {
111
103
case lhs( CopyableKlass )
112
104
case rhs( MoveOnlyKlass )
113
105
}
@@ -117,8 +109,7 @@ func foo() {
117
109
var moveOnly : MoveOnlyKlass ? = nil // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
118
110
}
119
111
120
- @_moveOnly
121
- class C3MoveOnly {
112
+ class C3MoveOnly : ~ Copyable {
122
113
var copyable : CopyableKlass ? = nil
123
114
var moveOnly : MoveOnlyKlass ? = nil // expected-error {{move-only type 'MoveOnlyKlass' cannot be used with generics yet}}
124
115
}
@@ -128,8 +119,7 @@ func foo() {
128
119
var moveOnly : MoveOnlyKlass // expected-note {{contained move-only property 'S3.moveOnly'}}
129
120
}
130
121
131
- @_moveOnly
132
- struct S3MoveOnly {
122
+ struct S3MoveOnly : ~ Copyable {
133
123
var copyable : CopyableKlass
134
124
var moveOnly : MoveOnlyKlass
135
125
}
@@ -139,8 +129,7 @@ func foo() {
139
129
case rhs( MoveOnlyKlass ) // expected-note {{contained move-only enum case 'E3.rhs'}}
140
130
}
141
131
142
- @_moveOnly
143
- enum E3MoveOnly {
132
+ enum E3MoveOnly : ~ Copyable {
144
133
case lhs( CopyableKlass )
145
134
case rhs( MoveOnlyKlass )
146
135
}
@@ -161,11 +150,11 @@ struct UnsafePointerWithOwner<T> {
161
150
// protocol.
162
151
protocol P { }
163
152
protocol Q { }
164
- @ _moveOnly class ProtocolCheckMoveOnlyKlass { }
165
- @ _moveOnly struct ProtocolCheckMoveOnlyStruct {
153
+ class ProtocolCheckMoveOnlyKlass : ~ Copyable { }
154
+ struct ProtocolCheckMoveOnlyStruct : ~ Copyable {
166
155
var k : MoveOnlyKlass
167
156
}
168
- @ _moveOnly enum ProtocolCheckMoveOnlyEnum { }
157
+ enum ProtocolCheckMoveOnlyEnum : ~ Copyable { }
169
158
170
159
extension ProtocolCheckMoveOnlyKlass : P { } // expected-error {{move-only class 'ProtocolCheckMoveOnlyKlass' cannot conform to 'P'}}
171
160
extension ProtocolCheckMoveOnlyStruct : P , Q { }
@@ -193,19 +182,15 @@ extension ProtocolCheckMoveOnlyStruct {}
193
182
extension ProtocolCheckMoveOnlyEnum { }
194
183
195
184
// Check if we define a move only type and make it conform on the base type
196
- @_moveOnly
197
- class MoveOnlyKlassP : P { } // expected-error {{move-only class 'MoveOnlyKlassP' cannot conform to 'P'}}
198
- @_moveOnly
199
- struct MoveOnlyStructP : P { // expected-error {{move-only struct 'MoveOnlyStructP' cannot conform to 'P'}}
185
+ class MoveOnlyKlassP : P , ~ Copyable { } // expected-error {{move-only class 'MoveOnlyKlassP' cannot conform to 'P'}}
186
+ struct MoveOnlyStructP : ~ Copyable, P { // expected-error {{move-only struct 'MoveOnlyStructP' cannot conform to 'P'}}
200
187
var mv : MoveOnlyKlass
201
188
}
202
- @_moveOnly
203
- enum MoveOnlyEnumP : P { } // expected-error {{move-only enum 'MoveOnlyEnumP' cannot conform to 'P'}}
189
+ enum MoveOnlyEnumP : ~ Copyable, P { } // expected-error {{move-only enum 'MoveOnlyEnumP' cannot conform to 'P'}}
204
190
205
191
// ensure there is no auto-synthesis of Equatable, Hashable, etc, for this move-only enum,
206
192
// because it normally would be synthesized since it only has cases without associated values.
207
- @_moveOnly
208
- enum Color {
193
+ enum Color : ~ Copyable {
209
194
case red
210
195
case green
211
196
case blue
@@ -216,8 +201,7 @@ enum Color {
216
201
}
217
202
}
218
203
219
- @_moveOnly
220
- enum StrengthLevel : Int { // ensure move-only raw enums do not conform to RawRepresentable
204
+ enum StrengthLevel : Int , ~ Copyable { // ensure move-only raw enums do not conform to RawRepresentable
221
205
case none = 0
222
206
case low
223
207
case high
0 commit comments