@@ -158,12 +158,28 @@ func checkCasting(_ b: any Box, _ mo: MO) {
158
158
_ = MO ( ) as any P // expected-error {{move-only type 'MO' cannot be used with generics yet}}
159
159
_ = MO ( ) as Any // expected-error {{move-only type 'MO' cannot be used with generics yet}}
160
160
_ = MO ( ) as MO
161
+ _ = MO ( ) as AnyObject // expected-error {{move-only type 'MO' cannot be used with generics yet}}
161
162
162
- // TODO: make sure at runtime these casts actually fail, or just make them errors?
163
- let _: AnyHashable = MO ( ) as! AnyHashable // expected-warning {{cast from 'MO' to unrelated type 'AnyHashable' always fails}}
163
+ // FIXME(kavon): make sure at runtime these casts actually fail, or just make them errors? (rdar://104900293)
164
+
165
+ _ = MO ( ) is AnyHashable // expected-warning {{cast from 'MO' to unrelated type 'AnyHashable' always fails}}
166
+ _ = MO ( ) is AnyObject // expected-warning {{cast from 'MO' to unrelated type 'AnyObject' always fails}}
167
+ _ = MO ( ) is Any // expected-warning {{cast from 'MO' to unrelated type 'Any' always fails}}
168
+ _ = MO ( ) is P // expected-warning {{cast from 'MO' to unrelated type 'any P' always fails}}
169
+ _ = MO ( ) is MO // expected-warning {{'is' test is always true}}
170
+
171
+ _ = MO ( ) as! AnyHashable // expected-warning {{cast from 'MO' to unrelated type 'AnyHashable' always fails}}
172
+ _ = MO ( ) as! AnyObject // expected-warning {{cast from 'MO' to unrelated type 'AnyObject' always fails}}
173
+ _ = MO ( ) as! Any // expected-warning {{cast from 'MO' to unrelated type 'Any' always fails}}
174
+ _ = MO ( ) as! P // expected-warning {{cast from 'MO' to unrelated type 'any P' always fails}}
175
+ _ = MO ( ) as! MO // expected-warning {{forced cast of 'MO' to same type has no effect}}
176
+
177
+ _ = MO ( ) as? AnyHashable // expected-warning {{cast from 'MO' to unrelated type 'AnyHashable' always fails}}
178
+ _ = MO ( ) as? AnyObject // expected-warning {{cast from 'MO' to unrelated type 'AnyObject' always fails}}
179
+ _ = MO ( ) as? Any // expected-warning {{cast from 'MO' to unrelated type 'Any' always fails}}
180
+ _ = MO ( ) as? P // expected-warning {{cast from 'MO' to unrelated type 'any P' always fails}}
181
+ _ = MO ( ) as? MO // expected-warning {{conditional cast from 'MO' to 'MO' always succeeds}}
164
182
165
- // TODO: figure out how this is getting past us! Doesn't seem to hit `typeCheckCheckedCast` at all!
166
- _ = MO ( ) as AnyObject // expected-error {{move-only type 'MO' cannot be used with generics yet}}
167
183
}
168
184
169
185
func checkStdlibTypes( _ mo: MO ) {
@@ -211,4 +227,4 @@ protocol Gives: HasType {
211
227
struct GenerousGuy : Gives { // expected-error {{type 'GenerousGuy' does not conform to protocol 'HasType'}}
212
228
typealias Ty = MO // expected-note {{possibly intended match 'GenerousGuy.Ty' (aka 'MO') does not conform to '_Copyable'}}
213
229
func give( ) -> Ty { }
214
- }
230
+ }
0 commit comments