Skip to content

Correctly print swift Int property as NSUInteger when it overrides an NSUInteger objc property. #66011

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 1 commit into from
May 22, 2023

Conversation

thunderseethe
Copy link
Contributor

Noticed odd behavior around objc generated headers, a swift property of type Int was being printed as NSInteger even though it overrides an ObjC property of type NSUInteger . Tracked it down to a change in clang where it looks like clang is now providing ElaboratedType instead of an unwrapped TypedefType as the QualType of ObjCPropertyDecl.

isNSUInteger tries to cast ElaboratedType to TypedefType, this fails as they are different classes and returns false. Updated isNSUInteger to check if clangTy is an ElaboratedType and desugar it first, before checking if clangTy is a TypedefType.

With this change we can re-enable the two disabled tests in PrintAsObjC as they are now passing again:

  • PrintAsObjC/availability-real-sdk
  • PrintAsObjC/override

Re-enable PrintAsObjC/availability-real-sdk and PrintAsObjC/override, they are now passing.
@allevato
Copy link
Member

@swift-ci please test

@allevato
Copy link
Member

@eeckstein You originally disabled these tests in 2862950. Does this seem reasonable to you? (We should also get this into 5.9.)

@allevato allevato requested a review from eeckstein May 19, 2023 13:59
Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

LGTM! Seems that I missed this in my patch for elaborated types (#62190) during the last rebranch.
Thanks @thunderseethe!

@egorzhdan egorzhdan requested a review from beccadax May 22, 2023 11:28
@egorzhdan egorzhdan merged commit c6d5216 into swiftlang:main May 22, 2023
tbkka pushed a commit that referenced this pull request Jun 2, 2023
Correctly print swift `Int` property as `NSUInteger` when it overrides an `NSUInteger` objc property.
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.

3 participants