mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When casting a class instance to a final class, we can directly compare the isa-pointer with address of the metadata. This avoids a call to `swift_dynamicCastClass`. It also avoids a call to the metadata accessor of the class (which calls `swift_getInitializedObjCClass`). For comparing the metadata pointers it's not required that the metadata is fully initialized.
19 lines
254 B
Swift
19 lines
254 B
Swift
|
|
public protocol P : AnyObject { }
|
|
|
|
public class Base {
|
|
public init() {}
|
|
}
|
|
|
|
public class Nonfinal : Base, P {
|
|
public override init() {}
|
|
}
|
|
|
|
final public class Final : Base, P {
|
|
public override init() {}
|
|
}
|
|
|
|
open class OpenBase {
|
|
public init() {}
|
|
}
|