struct AStruct {
var aValue: Int
}
let aStruct = AStruct(aValue: 3)
let aClass = aStruct as AnyObject //Why does this line compile?
let ident = ObjectIdentifier(aClass) //`ObjectIdentifier()` requires a reference object, but this code works
In the code above, I'm casting a struct, which is a value type, to AnyObject
(for class objects) and it works.
I would expect a compile error on that line.
In the next line I'm passing the struct, cast to AnyObject to ObjectIdentifier()
, which requires that it's parameter be a class object. That code runs, and returns a result. I would expect that line to crash at runtime if it was passed an Any
.
What the @#$@#?