Skip to content

Commit 3923e2e

Browse files
authored
Merge pull request #71443 from Azoy/fix-specialize-function
[stdlib] Fix _specialize implementation
2 parents c28b352 + 71fccd1 commit 3923e2e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/public/core/Builtin.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ public func _identityCast<T, U>(_ x: T, to expectedType: U.Type) -> U {
115115
/// This cast can be useful for dispatching to specializations of generic
116116
/// functions.
117117
@_alwaysEmitIntoClient
118+
@_transparent
118119
public func _specialize<T, U>(_ x: T, for: U.Type) -> U? {
119120
guard T.self == U.self else {
120121
return nil
121122
}
122123

123-
return Builtin.reinterpretCast(x)
124+
let result: U = Builtin.reinterpretCast(x)
125+
return result
124126
}
125127

126128
/// `unsafeBitCast` something to `AnyObject`.

0 commit comments

Comments
 (0)