Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13157] Swift compiler should not elide overridden class properties marked with @objc #55600

Open
swift-ci opened this issue Jul 6, 2020 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 6, 2020

Previous ID SR-13157
Radar None
Original Reporter Kentzo (JIRA User)
Type Bug
Environment

Apple Swift version 5.1.3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 71d3ea58c1bb2848d7e06568181d41f6

Issue Description:

In Objective-C it's not uncommon to check in runtime whether a particular class re-implements a method or property for "conformance" tests. It is important to make sure that Swift retains this behavior and does not elide declarations attributed with `@objc`.

In Apple's Foundation there the `NSSecureCoding` protocol. Every class and every subclass must implement the `supportsSecureCoding` class property to confirm and re-confirm conformance.

@objcMembers class A: NSObject, NSSecureCoding {
    public class var supportsSecureCoding: Bool { true }
    // ...
}

@objcMembers class B: A {
    override public class var supportsSecureCoding: Bool { true } // <-- elided
    // ...
}

Currently, when compiled with optimizations for Release, the override is elided and an attempt to archive via `try! NSKeyedArchiver.archivedData(withRootObject: B(), requiringSecureCoding: true)` fails with an error because the runtime check saw implementation in `A` but haven't seen one in `B`.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant