Skip to content
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

Replaced Any uses for workaround with Box #2250

Merged
merged 2 commits into from
Feb 7, 2023
Merged

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented Jan 27, 2023

See swiftlang/swift#58099
This is fixed in newer versions of Xcode, but we still need the workaround for older ones. Instead of using Any and force-casting, Box is better since it's type safe.

Other changes:

  • Moved Box to RevenueCat to be able to use the workaround there too.
  • Made Box immutable. It's very dangerous to have a reference value (Box is a class) with reference semantics be mutable. Instead, we force users to have a mutable property instead and re-create the Box, to avoid mutating that data under the hood.
  • Updated the comments to point to the new Swift GitHub issue page.

@NachoSoto NachoSoto added the refactor A code change that neither fixes a bug nor adds a feature label Jan 27, 2023
@NachoSoto NachoSoto requested a review from a team January 27, 2023 17:32
See swiftlang/swift#58099
This is fixed in newer versions of Xcode, but we still need the workaround for older ones. Instead of using `Any` and force-casting, `Box` is better since it's type safe.

I've also updated the comments to point to the new `Swift` GitHub issue page.
final class Box<T> {

var value: T
let value: T
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ No longer mutable

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #2250 (bda60d3) into main (c765b18) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2250      +/-   ##
==========================================
+ Coverage   85.90%   85.99%   +0.09%     
==========================================
  Files         183      184       +1     
  Lines       12125    12127       +2     
==========================================
+ Hits        10416    10429      +13     
+ Misses       1709     1698      -11     
Impacted Files Coverage Δ
Sources/Misc/Box.swift 100.00% <ø> (ø)
...chasing/StoreKitAbstractions/SK2StoreProduct.swift 96.72% <100.00%> (ø)
Sources/Logging/Strings/StoreKitStrings.swift 91.17% <0.00%> (+1.47%) ⬆️
Sources/Logging/Strings/NetworkStrings.swift 100.00% <0.00%> (+1.63%) ⬆️
Sources/Networking/HTTPClient/HTTPClient.swift 98.20% <0.00%> (+3.23%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@NachoSoto NachoSoto merged commit cf3090a into main Feb 7, 2023
@NachoSoto NachoSoto deleted the remove-box-workaround branch February 7, 2023 14:51
NachoSoto pushed a commit that referenced this pull request Feb 8, 2023
**This is an automatic release.**

### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `738f255` to `9255366`
(#2264) via dependabot[bot] (@dependabot[bot])
* Update `Gemfile.lock` (#2254) via Cesar de la Vega (@vegaro)
### Other Changes
* `HTTPClient`: added support for sending `X-Nonce` (#2214) via
NachoSoto (@NachoSoto)
* `Configuration`: added (`internal` for now) API to load public key
(#2215) via NachoSoto (@NachoSoto)
* Replaced `Any` uses for workaround with `Box` (#2250) via NachoSoto
(@NachoSoto)
* `HTTPClientTests`: fixed failing test with missing assertions (#2262)
via NachoSoto (@NachoSoto)
* `HTTPClientTests`: refactored tests to use `waitUntil` (#2257) via
NachoSoto (@NachoSoto)
* PurchaseTester: Add Receipt Inspector UI (#2249) via Andy Boedo
(@aboedo)
* Adds dependabot (#2259) via Cesar de la Vega (@vegaro)
* `StoreKit1WrapperTests`: avoid using `Bool.random` to fix flaky code
coverage (#2258) via NachoSoto (@NachoSoto)
* `IntroEligibilityCalculator`: changed logic to handle products with no
subscription group (#2247) via NachoSoto (@NachoSoto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants