-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[SR-2416] allow non-NSObject types to be archived #574
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
Conversation
26104f2
to
da3d6ef
Compare
I'm pretty sure you can't archive non-NSObject classes on Darwin either, actually. |
@swift-ci please test |
|
Yes, thanks for the reminder. |
Build failure:
|
It builds fine with the XCode 8.0 toolchain, I’ll try with a recent snapshot and fix any errors. |
It's probably a cross-platform problem with bridging on Linux; I don't think building in Xcode will show the issue. |
OK, should I just make the change suggested by the compiler below then? I can’t test on Linux right now (just off a 30 hour flight).
www.lukehoward.com |
I think that'll just end up creating a warning on Mac. @phausler what's the right incantation here? |
It does create a warning on Mac :( Sent from my iPhone
|
// test both XML and binary encodings | ||
test_archive(object, classes: classes, allowsSecureCoding: allowsSecureCoding, outputFormat: PropertyListSerialization.PropertyListFormat.xml) | ||
test_archive(object, classes: classes, allowsSecureCoding: allowsSecureCoding, outputFormat: PropertyListSerialization.PropertyListFormat.binary) | ||
} | ||
|
||
private func test_archive(_ object: NSObject, allowsSecureCoding: Bool = true) { | ||
return test_archive(object, classes: [type(of: object)], allowsSecureCoding: allowsSecureCoding) | ||
private func test_archive(_ object: Any, allowsSecureCoding: Bool = true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be NSObject
or AnyObject
still.
This patch fixes a number of issues that were preventing non-NSObject types from being archived, even though the new method signatures imply that they can be (by taking Any). * fix regression introduced aa504dc where non-hashable objects could not be encoded * fix bug where non-NSObjects would be replaced with nil, causing a crash * remove explicit check that the encoded object is a NSObject * possibly should be a separate patch: transparently bridge value types to the corresponding reference type before encoding * tests for all over the above
Fixed.
www.lukehoward.com |
@swift-ci please test |
This build failure doesn't seem to be SwiftFoundation related? |
Yah, let's try that again. |
@swift-ci please test |
@swift-ci please test and merge |
[pull] swiftwasm from main
This patch fixes a number of issues that were preventing non-NSObject types from being archived, even though the new method signatures imply that they can be (by taking Any).