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
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to