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-11926] FileHandle's new APIs should be more open on Linux. #3369
Comments
@swift-ci create |
Due to implementation details on Darwin, it is not possible to correctly subclass FileHandle on that platform. (There is no designated initializer that will not throw an exception.) SCF just codifies this behavior explicitly. |
(To be clear: in Swift. You can correctly subclass FileHandle on Darwin, because you can avoid invoking a superclass's initializer there.) |
(… in ObjC) |
Thank you for the response. There are some cases where subclasses of If Apple does not allow making subclasses of
|
List: APIs of
|
____________________________________ | ObjC (macOS<10.15) | ObjC (macOS>=10.15) | Swift (macOS<10.15) | Swift (macOS>=10.15) | Swift<5.0 w/SwiftFoundation | Swift>=5.0 w/SwiftFoundation |
---|---|---|---|---|---|---|
Legacy methods (e.g. closeFile() ) |
Overridable | Overridable(deprecated) | open |
open (deprecated) |
open |
open (deprecated) |
New methods (e.g. close() throws ) |
Overridable | Overridable | n/a | open |
n/a | public |
Other methods | Overridable | Overridable | open |
open |
open |
open |
Making subclasses | Available | Available | Available | Available | Available | Available |
Making useful subclasses | Available | Available | Available with workarounds | Available with workarounds | Available | Unavailable |
SCF seems not to codify the behavior on Darwin...
Environment
Swift 5.1.2
macOS 10.15.1
Ubuntu 18.04
Additional Detail from JIRA
md5: 31f5454e066ba5b5796a2f74a425e0c6
Issue Description:
From Swift 5.0, new APIs of
FileHandle
are introduced.Some of them are common between DarwinFoundation and SwiftFoundation such as below:
func close() throws
func seek(toOffset: UInt64) throws
func synchronize() throws
func truncate(atOffset: UInt64) throws
While they are defined as
open
in DarwinFoundation (as you know they are imported from objc), they arepublic
in SwiftFoundation.They should be defined as
open
also in SwiftFoundation to ensure compatibility (for example, making subclasses ofFileHandle
in other modules).The text was updated successfully, but these errors were encountered: