[SR-10286] Swift 5 Metadata documentation is out of date #52686
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
documentation
runtime
The Swift Runtime
Additional Detail from JIRA
md5: dab758796316c8ab4c094a6309ade70a
Issue Description:
The documentation on the type metadata layout for Swift 5 needs to be updated.
If I run the following code:
func printFromMemory (_ ty: Any.Type) {
{{ let p = unsafeBitCast(ty, to: UnsafePointer<Int>.self)}}
{{ let s = String (p.pointee, radix: 16)}}
{{ print (s)}}
{{}}}
public enum OnIt {
{{ case ItsOff, ItsOn}}
{{}}}
public struct Foo {
{{ public var x: Int}}
{{}}}{{ }}
public class Bar {
{{ public init () { }}}
{{}}}{{ }}
public protocol Proto {
{{ func nothing()}}
{{}}}{{ }}
print ("class")
printFromMemory (Bar.self)
print ("struct")
printFromMemory (Foo.self)
print ("optional")
printFromMemory(Int?.self)
print ("enum")
printFromMemory (OnIt.self)
print ("tuple")
printFromMemory(type(of🙁3, false)))
print ("function")``printFromMemory((()->()).self)
print ("protocol")``printFromMemory(Proto.self)
I get the following output :
class
1d8001000032c9
struct
200
optional
202
enum
201
tuple
301
function
302
protocol
303
This is clearly not the Kind field as described in the document but appears to have the bits spread out over the bottom 2 bytes? What is the layout now?
The text was updated successfully, but these errors were encountered: