-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Workaround for difference in behavior between optimizer and runtime understanding of casts (2.2) #1990
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
Workaround for difference in behavior between optimizer and runtime understanding of casts (2.2) #1990
Conversation
We have a special rule that Optional<T>.none successfully dynamically casts to Optional<U>.none for any T and U. However the implementation was incorrect if the source and destination types had a different size. We would initialize the source to nil, and then copy to the result. The correct implementation is to initialize the result using the result payload type directly, and not call _succeed() at all. Fixes <https://bugs.swift.org/browse/SR-1056>.
Until we fix the optimizer to produce the same results as runtime casts, let's inhibit optimizations.
@swift-ci Please test |
@tkremenek Note that swift-ci Please test doesn't actually run with optimizations, which is why this slipped through in the first place. It would be great if we could fix that. |
@swift-ci test |
Yeah, running without optimization bit me too recently. |
@tkremenek Is the 'Please' optional now? :) |
Maybe it has INTERCAL semantics, where it rejects your request if you don't use the right percentage of times. |
This is a simple runtime fix for the following case: func cast<U>(t: Any) -> U { return t as! U } cast(nil as Int?) as Int?
@swift-ci Please test |
@tkremenek I'll do one final test run of this and my other 2.2.1 PRs with check-swift-all-optimized -- will update here when its done. |
@slavapestov Yes, that's the right _semantic to use to disable specialization of that function (and any optimization within the function). |
@tkremenek Can you merge this one please? |
@rudkx Is this right?