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

fix: ObjectData type check #459

Merged
merged 5 commits into from
Aug 13, 2024
Merged

fix: ObjectData type check #459

merged 5 commits into from
Aug 13, 2024

Conversation

calvincestari
Copy link
Member

Fixes apollographql/apollo-ios#3414

Checking whether AnyHashable can be cast to a Bool is not enough to infer behaviour from the original type. The only way to do that is to compare against the two possible Bool values; true and false. This is possible because of the way AnyHashable does equality comparison.

@calvincestari calvincestari changed the title fix: ObjectData Int/Bool value check fix: ObjectData Int/Bool value check Aug 13, 2024
Copy link

netlify bot commented Aug 13, 2024

Deploy Preview for apollo-ios-docc canceled.

Name Link
🔨 Latest commit b881a48
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docc/deploys/66bbbb8829644000085d2d8d

Copy link

netlify bot commented Aug 13, 2024

Deploy Preview for eclectic-pie-88a2ba canceled.

Name Link
🔨 Latest commit b881a48
🔍 Latest deploy log https://app.netlify.com/sites/eclectic-pie-88a2ba/deploys/66bbbb8820f9dd000837e9d7

@calvincestari calvincestari changed the title fix: ObjectData Int/Bool value check fix: ObjectData type check Aug 13, 2024
@calvincestari
Copy link
Member Author

Putting this into draft since I realized it can't use the static constants due to being a public function.

@calvincestari calvincestari marked this pull request as draft August 13, 2024 14:13
@calvincestari calvincestari marked this pull request as ready for review August 13, 2024 18:20
@calvincestari
Copy link
Member Author

I can't think of a better non-intrusive way to fix this. The static constants needed to be made public because the ObjectData subscript is public. I don't like that they're public but I've underscored them to signal their 'private' intent and having them as static constants negates the performance cost of having to create them for each comparison.

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

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

Would like us to try using @usableFromInline for those constants. Otherwise this LGTM!

apollo-ios/Sources/ApolloAPI/ObjectData.swift Outdated Show resolved Hide resolved
@calvincestari calvincestari merged commit 192e0e3 into main Aug 13, 2024
37 checks passed
@calvincestari calvincestari deleted the fix/issue3424 branch August 13, 2024 20:54
BobaFetters pushed a commit that referenced this pull request Aug 13, 2024
BobaFetters pushed a commit to apollographql/apollo-ios that referenced this pull request Aug 13, 2024
BobaFetters pushed a commit that referenced this pull request Aug 13, 2024
1da33d37 fix: `ObjectData` type check (#459)
65d7a19e Update ROADMAP.md

git-subtree-dir: apollo-ios
git-subtree-split: 1da33d37db8fadaa426e3d2493a9dbddb4617308
BobaFetters pushed a commit that referenced this pull request Aug 13, 2024
git-subtree-dir: apollo-ios
git-subtree-mainline: dd2193b
git-subtree-split: 1da33d37db8fadaa426e3d2493a9dbddb4617308
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.

CacheKeyInfo with a numeric jsonValue of 1 returns nil
2 participants