File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class B: A {}
16
16
class C < T> { }
17
17
class D : C < Int > { }
18
18
19
+ class N < T> { }
20
+
19
21
func castAToB( a: A ) -> B {
20
22
// expected-warning@+1{{'unsafeBitCast' from 'A' to 'B' can be replaced with 'unsafeDowncast'}} {{7-20=unsafeDowncast}}
21
23
_ = unsafeBitCast ( a, to: B . self)
@@ -29,6 +31,10 @@ func castCToD<T>(c: C<T>) -> D {
29
31
return unsafeBitCast ( c, to: D . self)
30
32
}
31
33
34
+ func castNToD< T> ( n: N < T > ) -> D {
35
+ return unsafeBitCast ( n, to: D . self) // CHECK-NOT: warning
36
+ }
37
+
32
38
func castDToC< T> ( d: D ) -> ( C < T > , C < Int > ) {
33
39
let a = unsafeBitCast ( d, to: C< T> . self ) // not necessarily a no-op if T != Int
34
40
// expected-warning@+1{{'unsafeBitCast' from 'D' to 'C<Int>' is unnecessary}}{{11-25=}}{{26-44=}}
You can’t perform that action at this time.
0 commit comments