@@ -165,13 +165,19 @@ internal func != (lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
165165/// - t1: Another type to compare.
166166/// - Returns: `true` if both `t0` and `t1` are `nil` or if they represent the
167167/// same type; otherwise, `false`.
168- @inlinable @_transparent
169- public func == ( t0: Any . Type ? , t1: Any . Type ? ) -> Bool {
168+ @_alwaysEmitIntoClient
169+ @_transparent
170+ public func == (
171+ t0: ( any ( ~ Copyable & ~ Escapable) . Type) ? ,
172+ t1: ( any ( ~ Copyable & ~ Escapable) . Type) ?
173+ ) -> Bool {
170174 switch ( t0, t1) {
171- case ( . none, . none) : return true
175+ case ( . none, . none) :
176+ return true
172177 case let ( . some( ty0) , . some( ty1) ) :
173178 return Bool ( Builtin . is_same_metatype ( ty0, ty1) )
174- default : return false
179+ default :
180+ return false
175181 }
176182}
177183
@@ -182,11 +188,35 @@ public func == (t0: Any.Type?, t1: Any.Type?) -> Bool {
182188/// - t1: Another type to compare.
183189/// - Returns: `true` if one, but not both, of `t0` and `t1` are `nil`, or if
184190/// they represent different types; otherwise, `false`.
185- @inlinable @_transparent
186- public func != ( t0: Any . Type ? , t1: Any . Type ? ) -> Bool {
187- return !( t0 == t1)
191+ @_alwaysEmitIntoClient
192+ @_transparent
193+ public func != (
194+ t0: ( any ( ~ Copyable & ~ Escapable) . Type) ? ,
195+ t1: ( any ( ~ Copyable & ~ Escapable) . Type) ?
196+ ) -> Bool {
197+ !( t0 == t1)
188198}
189199
200+ #if !$Embedded
201+ // Embedded Swift is unhappy about conversions from `Any.Type` to
202+ // `any (~Copyable & ~Escapable).Type` (rdar://145706221)
203+ @usableFromInline
204+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 1 )
205+ internal func == ( t0: Any . Type ? , t1: Any . Type ? ) -> Bool {
206+ switch ( t0, t1) {
207+ case ( . none, . none) : return true
208+ case let ( . some( ty0) , . some( ty1) ) :
209+ return Bool ( Builtin . is_same_metatype ( ty0, ty1) )
210+ default : return false
211+ }
212+ }
213+
214+ @usableFromInline
215+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 1 )
216+ internal func != ( t0: Any . Type ? , t1: Any . Type ? ) -> Bool {
217+ !( t0 == t1)
218+ }
219+ #endif
190220
191221/// Tell the optimizer that this code is unreachable if condition is
192222/// known at compile-time to be true. If condition is false, or true
@@ -940,9 +970,11 @@ func _trueAfterDiagnostics() -> Builtin.Int1 {
940970///
941971/// - Parameter value: The value for which to find the dynamic type.
942972/// - Returns: The dynamic type, which is a metatype instance.
943- @_transparent
973+ @_alwaysEmitIntoClient
944974@_semantics ( " typechecker.type(of:) " )
945- public func type< T, Metatype> ( of value: T ) -> Metatype {
975+ public func type< T: ~ Copyable & ~ Escapable, Metatype> (
976+ of value: borrowing T
977+ ) -> Metatype {
946978 // This implementation is never used, since calls to `Swift.type(of:)` are
947979 // resolved as a special case by the type checker.
948980 unsafe Builtin. staticReport ( _trueAfterDiagnostics ( ) , true . _value,
@@ -951,6 +983,17 @@ public func type<T, Metatype>(of value: T) -> Metatype {
951983 Builtin . unreachable ( )
952984}
953985
986+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 1 )
987+ @_silgen_name ( " $ss4type2ofq_x_tr0_lF " )
988+ @usableFromInline
989+ func __abi_type< T, Metatype> ( of value: T ) -> Metatype {
990+ // This is a legacy entry point for the original definition of `type(of:)`
991+ // that the stdlib originally exported for no good reason. The current
992+ // definition no longer exports a symbol, and nothing is expected to link to
993+ // it, but we keep it around anyway.
994+ Builtin . unreachable ( )
995+ }
996+
954997/// Allows a nonescaping closure to temporarily be used as if it were allowed
955998/// to escape.
956999///
0 commit comments