[swift-evolution] [Discussion] Seal `T.Type` into `Type<T>`
Adrian Zubarev
adrian.zubarev at devandartist.com
Thu Jul 14 16:20:02 CDT 2016
I must correct the dynamicType implementation. It’s true that the function will produce Type<T> but we still need to extract the dynamic metatype from the value, store it in _underlyingMetatype and recalculate _uniqueIdentifier.
public func `dynamicType`<T>(_ instance: T) -> Metatype<T> {
let dynamicMetatype = /* extract from `instance` */
let rawPointerMetatype = unsafeBitCast(dynamicMetatype, to: Builtin.RawPointer.metatype)
var type = Type<T>()
type._underlyingMetatype = dynamicMetatype
type._uniqueIdentifier = Int(Builtin.ptrtoint_Word(rawPointerMetatype))
return type
}
--
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160714/cf5e5f54/attachment.html>
More information about the swift-evolution
mailing list