Skip to content

[IRGen] Respect optionality of unowned(unsafe) reference properties #65663

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

Merged
merged 2 commits into from
May 5, 2023

Conversation

drexin
Copy link
Contributor

@drexin drexin commented May 4, 2023

rdar://108705703

When generating the type info for fields marked unowned(unsafe) of an optional reference (e.g. AnyObject?), we dropped the fact that it was optional along the way. This caused incorrect tags to be returned when on object of the type was stored in an optional itself and the unowned property contained nil. In those cases the outer optional appeared to be nil as well, even if it in fact contained a value.

@drexin drexin requested a review from aschwaighofer May 4, 2023 17:38
@drexin
Copy link
Contributor Author

drexin commented May 4, 2023

@swift-ci smoke test

rdar://108705703

When generating the type info for fields marked unowned(unsafe) of an optional reference (e.g. AnyObject?), we dropped the fact that it was optional along the way. This caused incorrect tags to be returned when on object of the type was stored in an optional itself and the unowned property contained `nil`. In those cases the outer optional appeared to be `nil` as well, even if it in fact contained a value.
@drexin
Copy link
Contributor Author

drexin commented May 4, 2023

@swift-ci smoke test

@drexin
Copy link
Contributor Author

drexin commented May 4, 2023

Hm, I tested with a simplified test case and while it fixes that one, it does not seem to fix the original issue. Looking further into it.

@drexin
Copy link
Contributor Author

drexin commented May 4, 2023

@swift-ci smoke test

@drexin
Copy link
Contributor Author

drexin commented May 4, 2023

@aschwaighofer Fixed the other case as well. Ready for review.

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

great find!

@drexin
Copy link
Contributor Author

drexin commented May 5, 2023

@swift-ci smoke test macos

@drexin drexin merged commit 6d031cb into swiftlang:main May 5, 2023
drexin added a commit to drexin/swift that referenced this pull request May 5, 2023
…wiftlang#65663)

* [IRGen] Respect optionality of unowned(unsafe) reference properties

rdar://108705703

When generating the type info for fields marked unowned(unsafe) of an optional reference (e.g. AnyObject?), we dropped the fact that it was optional along the way. This caused incorrect tags to be returned when on object of the type was stored in an optional itself and the unowned property contained `nil`. In those cases the outer optional appeared to be `nil` as well, even if it in fact contained a value.

* Fix additional case
drexin added a commit that referenced this pull request May 5, 2023
…65663) (#65701)

* [IRGen] Respect optionality of unowned(unsafe) reference properties

rdar://108705703

When generating the type info for fields marked unowned(unsafe) of an optional reference (e.g. AnyObject?), we dropped the fact that it was optional along the way. This caused incorrect tags to be returned when on object of the type was stored in an optional itself and the unowned property contained `nil`. In those cases the outer optional appeared to be `nil` as well, even if it in fact contained a value.

* Fix additional case
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.

2 participants