-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Allow virtual methods to be renamed with SWIFT_NAME #82485
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci please smoke test |
@@ -318,11 +318,13 @@ class SwiftDeclSynthesizer { | |||
ReferenceReturnTypeBehaviorForBaseMethodSynthesis | |||
referenceReturnTypeBehavior = | |||
ReferenceReturnTypeBehaviorForBaseMethodSynthesis::KeepReference, | |||
bool forceConstQualifier = false); | |||
bool forceConstQualifier = false, | |||
std::optional<importer::ImportedName> importedName = std::nullopt); |
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.
Hmm, I'd say it isn't really clear here when the importedName
needs to be non-null, and when it can be null.
|
||
/// Given an overload of a C++ virtual method on a reference type, create a | ||
/// method that dispatches the call dynamically. | ||
FuncDecl *makeVirtualMethod(const clang::CXXMethodDecl *clangMethodDecl); | ||
FuncDecl *makeVirtualMethod(const clang::CXXMethodDecl *clangMethodDecl, | ||
importer::ImportedName importedName); |
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.
Can we remove this parameter and call importName
from the implementation of this method?
lib/ClangImporter/ImportDecl.cpp
Outdated
if (!importedName) | ||
return nullptr; |
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.
I think we can rely on the name not being nullptr if we got to this point.
What is the model here? If someone renames a virtual function do they need to rename all the overrides? What happens if an override is not renamed? |
That's a good question! At the moment, if you don't add the attribute to the override, you can call it by using either the original name or the It's a bit messy, we should come up with a better model. |
I see, thanks for elaborating! Maybe it would be great to have test for the cases you mentioned. I don't have a strong opinion about what we want to do here but in case we make it more strict in the future that would be a source breaking change. I think the options we have:
I do not have a strong opinion which one is the best. As long as we do not rush this to 6.2, I am OK merging this as is and figuring out what we want to do before the next stable release. |
9a3fd10
to
c10dbc4
Compare
@swift-ci please smoke test |
c10dbc4
to
9838de6
Compare
@swift-ci please smoke test |
The
swift_name
attribute can now be used to rename virtual methods.rdar://152583825