-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Foundation: more idiomatic Swift in NSKeyedArchiver #3160
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
8f63470
to
9f01961
Compare
I am interested in code that aligns behavior, but I'm less interested in code that modifies e.g. object identity to look like Darwin's unless that is something that a user could detect or that changes the semantics of their code. Is it? |
In general, we've spent so much work moving away from the factory self pattern I'm not super interested in having people spend effort to reverse that. |
Fair enough. Note, though, that the |
Those are arguments I can buy on deviating from these principles. Let me look. |
@swift-ci please test |
Four tests failing here:
|
9f01961
to
8d29107
Compare
There was a bug in the test when constructing the list of expected classes, it was expecting the concrete type (reported by |
@swift-ci please test |
Any updates on this @parkera |
Are you able to run an automated test again? Don't think I can do it |
@swift-ci test |
OK, still breaking on test, investigating. |
Use first(where:) in NSSpecialValue instead of iterating loop, as it is more idiomatic.
Eliminate some force-unwrap/force-casts in NSKeyedArchiver and NSKeyedUnarchiver. Some notes about whether unarchiver delegate is called when decoding nil objects.
Unwrapped variable can have same name as optional.
8d29107
to
6be1bcf
Compare
OK, perhaps this will fix it... |
@swift-ci test |
Seems to pass tests, I also rebased against main when fixing, ready for review I guess? |
Just following up on this one. |
Thanks! |
Originally when I implemented
NSValue
, I intended for it to be a class cluster with the concrete classes beingNSSpecialValue
orNSConcreteValue
. At the time, Swift didn't support this pattern. Now it does support reassigningself
(also see 00737ae), it makes sense to revisit this.Also, make some other related code paths more idiomatically Swift, by eliminating force-unwrap and force-cast; at the time, I was less familiar with Swift.
Unfortunately since I cannot build the TestFoundation target on macOS, it's not possible for me to run the tests (I don't have a Linux VM handy right now).