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-2170] Linux Linker error when deriving a class from NSURL #4454
Comments
Comment by Dave Sperling (JIRA) The problem persists with the Linux 0725 toolchain. import Foundation
public class URLParser : NSURL {
public init(url: Data) {
super.init(string: String(data: url, encoding: String.Encoding.utf8) ?? "", relativeTo: nil)!
}
// NSURL required initializers
required convenience public init(fileReferenceLiteralResourceName path: String) {
fatalError("init(fileReferenceLiteralResourceName:) has not been implemented")
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
let _ = URLParser(url: "https://swift.org".data(using: String.Encoding.utf8)!) |
Comment by David Grove (JIRA) Problem still present with Linux 0830 toolchain. Updated test case below: import Foundation
public class URLParser : NSURL {
public init(url: Data) {
super.init(string: String(data: url, encoding: String.Encoding.utf8) ?? "", relativeTo: nil)!
}
// NSURL required initializers
required convenience public init(fileReferenceLiteralResourceName path: String) {
fatalError("init(fileReferenceLiteralResourceName:) has not been implemented")
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
let _ = URLParser(url: "https://swift.org".data(using: String.Encoding.utf8)!) |
Comment by David Grove (JIRA) This is a general problem with subclassing an open class with internal members external to the defining library. For example, the code below also fails with linker errors: import Foundation
public class MyOperation : Operation {
}
let o = MyOperation() |
Another example of this affecting corelibs API: #651 |
These now compile and link under recent versions of swift - the |
Environment
Linux Toolchain 0620 or Preview 2
Additional Detail from JIRA
md5: a5a07129f728b6f25484e450eb46d70d
relates to:
Issue Description:
The following code compiles but fails to link on Linux. Mac works OK.
The linker errors with:
The text was updated successfully, but these errors were encountered: