1414 import Darwin
1515#endif
1616
17+ // Here to silence builtin warnings for using unsafeBitCast with reference
18+ // types. The layout of all types in the STM is fixed (doesn't depend on the
19+ // generic parameter), so bit casts are always legal.
20+ private func transmute< T, U> ( _ x: T , to type: U . Type ) -> U {
21+ return unsafeBitCast ( x, to: type)
22+ }
23+
1724internal final class Entry {
1825 let ident : ObjectIdentifier
1926 let oldValue : TVarType < Any >
@@ -36,20 +43,20 @@ internal final class Entry {
3643 init < T> ( _ location : TVar < T > , _ value : TVarType < T > , _ valid : Bool ) {
3744 self . ident = ObjectIdentifier ( T . self)
3845 // HACK: bridge-all-the-things-to-Any makes this a legal transformation.
39- self . location = unsafeBitCast ( location, to: TVar< Any> . self )
46+ self . location = transmute ( location, to: TVar< Any> . self )
4047 // HACK: TVarType's layout doesn't depend on T.
41- self . oldValue = unsafeBitCast ( location. value, to: TVarType< Any> . self )
42- self . _newValue = unsafeBitCast ( value, to: TVarType< Any> . self )
48+ self . oldValue = transmute ( location. value, to: TVarType< Any> . self )
49+ self . _newValue = transmute ( value, to: TVarType< Any> . self )
4350 self . hasOldValue = valid
4451 }
4552
4653 private init < T> ( _ ident : ObjectIdentifier , _ oldValue : TVarType < T > , _ location : TVar < T > , _ value : TVarType < T > , _ valid : Bool ) {
4754 self . ident = ident
4855 // HACK: bridge-all-the-things-to-Any makes this a legal transformation.
49- self . location = unsafeBitCast ( location, to: TVar< Any> . self )
56+ self . location = transmute ( location, to: TVar< Any> . self )
5057 // HACK: TVarType's layout doesn't depend on T.
51- self . oldValue = unsafeBitCast ( oldValue, to: TVarType< Any> . self )
52- self . _newValue = unsafeBitCast ( value, to: TVarType< Any> . self )
58+ self . oldValue = transmute ( oldValue, to: TVarType< Any> . self )
59+ self . _newValue = transmute ( value, to: TVarType< Any> . self )
5360 self . hasOldValue = valid
5461 }
5562
@@ -136,7 +143,7 @@ internal final class TLog {
136143 if let entry = self . log [ location. hashValue] {
137144 precondition ( ObjectIdentifier ( T . self) == entry. ident)
138145 // HACK: TVarType's layout doesn't depend on T.
139- entry. _newValue = unsafeBitCast ( value, to: TVarType< Any> . self )
146+ entry. _newValue = transmute ( value, to: TVarType< Any> . self )
140147 } else {
141148 let entry = Entry ( location, value)
142149 log [ location. hashValue] = entry
0 commit comments