Skip to content

Commit 4c8c828

Browse files
committed
Rename to _specialize
1 parent e381815 commit 4c8c828

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

stdlib/public/core/Builtin.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,13 @@ public func _identityCast<T, U>(_ x: T, to expectedType: U.Type) -> U {
109109
return Builtin.reinterpretCast(x)
110110
}
111111

112-
/// Returns `x` as its concrete type `U`.
112+
/// Returns `x` as its concrete type `U`, or `nil` if `x` has a different
113+
/// concrete type.
113114
///
114115
/// This cast can be useful for dispatching to specializations of generic
115116
/// functions.
116-
///
117-
/// - Requires: `x` has type `U`.
118117
@_alwaysEmitIntoClient
119-
public func _conditionalIdentityCast<T, U>(_ x: T, to: U.Type) -> U? {
118+
public func _specialize<T, U>(_ x: T, for: U.Type) -> U? {
120119
guard T.self == U.self else {
121120
return nil
122121
}

test/stdlib/Builtins.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ tests.test("_isConcrete") {
307307
expectFalse(isConcrete_false(Int.self))
308308
}
309309

310-
tests.test("_conditionalIdentityCast") {
310+
tests.test("_specialize") {
311311
func something<T>(with x: some Collection<T>) -> Int {
312-
if let y = _conditionalIdentityCast(x, to: [Int].self) {
312+
if let y = _specialize(x, for: [Int].self) {
313313
return y[0]
314314
} else {
315315
return 1234567890
@@ -323,7 +323,7 @@ tests.test("_conditionalIdentityCast") {
323323
expectEqual(something(with: y), 1234567890)
324324

325325
let z: Any = [0, 1, 2, 3]
326-
expectNil(_conditionalIdentityCast(z, to: [Int].self))
326+
expectNil(_specialize(z, for: [Int].self))
327327
}
328328

329329
runAllTests()

0 commit comments

Comments
 (0)