Skip to content

[4.2 EARLY] Hack: Force UIEdgeInsets.zero to always come from the SDK #17149

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

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Jun 12, 2018

  • Explanation: The UIKit overlay has long had convenience properties UIEdgeInsets.zero and UIOffset.zero, as Swiftier versions of constants in the UIKit framework UIEdgeInsetsZero and UIOffsetZero. In the iOS 12 SDK, we (Apple) tried to switch over to using the real C constants, since there's no need to duplicate the logic in Swift. However, trying to keep both declarations around but with different availability led to a crash in deserialization, which (deliberately) doesn't respect availability. Instead, let's go all the way to using the framework declarations…even though that means hacking the importer a little to pretend that UIKit's already updated their API notes.

  • Scope: Affects UIEdgeInsetsZero and UIOffsetZero only.

  • Issue: SR-7879 / rdar://problem/40735990

  • Risk: Low. This is a targeted hack with very little chance of affecting anything else, and it should not make things worse either.

  • Testing: Added compiler regression tests.

  • Reviewed by: @moiseev

…17122)

...instead of relying on the one in the overlay in pre-4.2 versions of
Swift. This caused crashes in deserialization, which (deliberately)
doesn't respect availability.

There are three changes here:

- Remove UIEdgeInsets.zero and UIOffset.zero from the UIKit overlay.
- Always use the 4.2 name for UIEdgeInsetsZero and UIOffsetZero from
  the underlying UIKit framework. (This is the nested name.)
- Ignore the unavailability messages for those two constants in
  pre-4.2 Swift, since we're now relying on them being present.

The latter two, the compiler changes, can go away once UIKit's API
notes no longer specify different pre-4.2 behavior, but meanwhile we
need to keep compatibility with the SDKs released in Xcode 10b1.

https://bugs.swift.org/browse/SR-7879
(cherry picked from commit a6ae2d7)
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor Author

@swift-ci Please nominate

@jrose-apple
Copy link
Contributor Author

The source compat failures are the 20 projects that are XFAILed on master. Merging.

@jrose-apple jrose-apple merged commit 6681a13 into swiftlang:swift-4.2-branch-06-11-2018 Jun 12, 2018
@jrose-apple jrose-apple deleted the 4.2-EARLY-UIEdgeInsetsZero branch June 12, 2018 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant