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-7746] NSKeyedUnarchiver is effectively final in corelibs-foundation, but not on Darwin Foundation #3697

Open
swift-ci opened this issue May 23, 2018 · 3 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7746
Radar None
Original Reporter gmilos (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 853ed74247553bca5a25200d1c4cabd6

Issue Description:

The following piece of code compiles just fine on Darwin:

import Foundation

class MyKeyedUnarchiver: NSKeyedUnarchiver {
    override init(forReadingWith data: Data) {
        super.init(forReadingWith: data)
    }
}

_ = MyKeyedUnarchiver(forReadingWith: Data())

But fails on Linux (4.1, ubuntu 14.04) with:

Compile Swift Module 'KeyedUnarchiverSubclassing' (1 sources)
/Users/gmilos/Repos/KeyedUnarchiverSubclassing/Sources/KeyedUnarchiverSubclassing/main.swift:4:14: error: initializer does not override a designated initializer from its superclass
override init(forReadingWith data: Data) {
~~~~~~~~ ^
Foundation.NSKeyedUnarchiver:6:24: note: attempt to override convenience initializer here
public convenience init(forReadingWith data: Foundation.Data)
^
/Users/gmilos/Repos/KeyedUnarchiverSubclassing/Sources/KeyedUnarchiverSubclassing/main.swift:5:9: error: must call a designated initializer of the superclass 'NSKeyedUnarchiver'
super.init(forReadingWith: data)
^
Foundation.NSKeyedUnarchiver:6:24: note: convenience initializer is declared here
public convenience init(forReadingWith data: Foundation.Data)

@belkadan
Copy link

@itaiferber?

@itaiferber
Copy link
Contributor

I wasn't around when s-cl-f was being initially written, so I'm not sure why this was written this way — @phausler, @parkera, any background on why this is a convenience initializer? The real initializer is private, meaning that this class is un-subclassable unless you inherit all initializers.

@parkera
Copy link
Member

parkera commented May 23, 2018

I think NSKeyedArchiver is missing the NS_DESIGNATED_INITIALIZER decoration completely on Darwin, so perhaps there was not a right answer here in the first place.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants