Skip to content

Commit 696bbac

Browse files
committed
[stdlib] unsafeBitCast: generalize for ~Escapable input types
1 parent 9b322e3 commit 696bbac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/public/core/Builtin.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ func _canBeClass<T>(_: T.Type) -> Int8 {
9191
/// Returns: A new instance of type `U`, cast from `x`.
9292
@inlinable // unsafe-performance
9393
@_transparent
94+
@_preInverseGenerics
9495
@unsafe
95-
public func unsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
96+
public func unsafeBitCast<T: ~Escapable, U>(
97+
_ x: T, to type: U.Type
98+
) -> U {
9699
_precondition(MemoryLayout<T>.size == MemoryLayout<U>.size,
97100
"Can't unsafeBitCast between types of different sizes")
98101
return Builtin.reinterpretCast(x)

0 commit comments

Comments
 (0)