-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[c++-interop] Providing information about enum types from inferDefaultArgument #59421
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zoecarver
reviewed
Jun 14, 2022
zoecarver
reviewed
Jun 14, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some tests
5749dd4
to
a0084e3
Compare
With my latest changes almost all of the omitNeedlessWords differences presented in https://docs.google.com/spreadsheets/d/1FswVLDXhYPqufMsVfxhF5Q5l5PW19J_JcZq67Cai6KQ/edit#gid=0 are fixed: |
6f93671
to
0fe159d
Compare
…tArgument When ClangImporter::Implementation::inferDefaultArgument processes func/method arguments as part of omitNeedlessWordsInFunctionName it processes information about how the typenames for the parameters related to the parameter names to form a parameter names list. The parameter names list is used to determine if the argument label for a function should be clipped based on the typename. So for example a type like NSOrderedCollectionDifferenceCalculationOptions would cause a label ending with "Options" to get clipped so that for instance "withOptions" becomes simply "with". Unfortunately in the context of C++-Interop, the typename for the parameter often resolves to what the type backing the typedef or enum is and not the actual name of the typedef (so `typedef NSUInteger NSOrderedCollectionDifferenceCalculationOptions` resolves to a name of NSUInteger rather than NSOrderedCollectionDifferenceCalculationOptions). This patch seeks to collect a bit more information when processing NS_OPTIONS typedefs and providing that to the calling omitNeedlessWordsInFunctionName to handle more inteligently. In practice this fixes anywhere in Foundatio where `withOptions: NSOrderedCollectionDifferenceCalculationOptions` is used.
0fe159d
to
28375ae
Compare
Test cases added. |
@swift-ci please test |
NuriAmari
added a commit
to NuriAmari/swift
that referenced
this pull request
Feb 16, 2023
When Objective-c methods are imported into Swift, the labels are transforms to remove suffixes based on the type of the parameter. Due to the structure of NS_OPTION when importing in C++ mode, there is some special handling for this case introduced in PR swiftlang#59421. This patch fixes some of this hanlding for when a multi-word suffix needs removing, specifically 'ControlEvents' and 'ScrollPosition'.
NuriAmari
added a commit
to NuriAmari/swift
that referenced
this pull request
Feb 16, 2023
When Objective-c methods are imported into Swift, the labels are transforms to remove suffixes based on the type of the parameter. Due to the structure of NS_OPTION when importing in C++ mode, there is some special handling for this case introduced in PR swiftlang#59421. This patch fixes some of this hanlding for when a multi-word suffix needs removing, specifically 'ControlEvents' and 'ScrollPosition'.
NuriAmari
added a commit
to NuriAmari/swift
that referenced
this pull request
Feb 16, 2023
When Objective-c methods are imported into Swift, the labels are transforms to remove suffixes based on the type of the parameter. Due to the structure of NS_OPTION when importing in C++ mode, there is some special handling for this case introduced in PR swiftlang#59421. This patch fixes some of this hanlding for when a multi-word suffix needs removing, specifically 'ControlEvents' and 'ScrollPosition'.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When ClangImporter::Implementation::inferDefaultArgument processes
func/method arguments as part of omitNeedlessWordsInFunctionName it
processes information about how the typenames for the parameters related
to the parameter names to form a parameter names list. The parameter
names list is used to determine if the argument label for a function
should be clipped based on the typename. So for example a type like
NSOrderedCollectionDifferenceCalculationOptions would cause a label
ending with "Options" to get clipped so that for instance "withOptions"
becomes simply "with".
Unfortunately in the context of C++-Interop, the typename for the
parameter often resolves to what the type backing the typedef or enum is
and not the actual name of the typedef
(so
typedef NSUInteger NSOrderedCollectionDifferenceCalculationOptions
resolves to a name of NSUInteger rather than
NSOrderedCollectionDifferenceCalculationOptions).
This patch seeks to collect a bit more information when processing
NS_OPTIONS typedefs and providing that to the calling
omitNeedlessWordsInFunctionName to handle more inteligently.
In practice this fixes anywhere in Foundatio where
withOptions: NSOrderedCollectionDifferenceCalculationOptions
is used.NOTE: This is a work in progress. Still trying to figure out how to reduce a good test case.