type(of: t) === BasicClass.self
// evaluate to true, if the class is identical, evaluates to false if t is a subclass of BasicClass
type(of: t) is BasicClass.Type
// evalutes to true if t is the same class as BasicClass OR if it is a subclass of BasicClass
So coming from a pure Swift perspective, I would wish this to evaluate to the same result in Silver.
I have virtually no experience with .NET, so I can’t comment whether it is consistent there.
I hear you, but unfortunately, there’s gray areas between what is Swift, the language, (which Silver supports), and what is Swift, the platform/class model (which, when you’re running on .NET is not the same, because these are CLR classes, not SwiftABI classes). And .NET Classes and their relationship to their meta classes is driven by how the object model works on .NET, not by the language.
That said, I’ll bring this up with the team for discussion as there’s at least one other inconsistency i’d like to have looked at — it seems that calling init isn’t virtual and calling init on ConsoleApplication25.AdvancedClass+MetaClass creates a BasicClass. which does seem wrong.
Logged as bugs://E26212: Swift: inconsistent result for {metaclass}.init()
let a = AdvancedClass.self
let x = a.init()
writeLn("x \(x)") // AdvancedClass, correct
for (i, c) in classes.enumerated() {
writeLn("i \(i)")
let t = c.init()
writeLn("c \(c)") // proper metaclass from array for both cases
writeLn("t \(t)") // BasicClass, both times
}
//x ConsoleApplication25.AdvancedClass
//i 0
//c ConsoleApplication25.BasicClass+MetaClass
//t ConsoleApplication25.BasicClass
//i 1
//c ConsoleApplication25.AdvancedClass+MetaClass
//t ConsoleApplication25.BasicClass //// <<<< THIS ONE IS WRONG
it seems that calling init isn’t virtual and calling init on ConsoleApplication25.AdvancedClass+MetaClass creates a BasicClass . which does seem wrong.
Would this explain also the observation, that AdvancesClass.someFunction() doesn’t print() if called in Silver?