-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Name translation: Allow type name translation when cursor points to constructor call. rdar://33163114 #10872
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
Conversation
…onstructor call. rdar://33163114 When translating objc names to swift names, if the given name is not an objc function name, and the cursor points to a contructor call, we use the type declaration instead of the init declaration to translate.
@swift-ci please smoke test |
@benlangmuir does this look safe for swift 4.0? |
// FIXME: Should pass the main module for the interface but currently | ||
// it's not necessary. | ||
passNameInfoForDecl(Entity.Dcl, NewInput, Receiver); |
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.
Why doesn't this break anything?
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.
This is for generated interface; we don't run name translation on that.
@@ -66,6 +67,7 @@ class MyDerived: FooClassDerived { | |||
// CHECK9: fooProperty11 | |||
// CHECK10: init(nstanceFunc21:) | |||
// CHECK11: init(lassDerived2:) | |||
// CHECK11-1: FooClassDerived2 |
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.
What about the other direction (Swift to Objc)?
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.
This should only happen on Objc->Swift, right? where cursor is selected by indexer at a random place. For the other direction, we actually have the cursor user points to,
so we don’t need this modification.
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.
Renaming from the Foo
in Foo(x: 1)
will currently rename the typename, which tries to name-translate the initializer name, leading to broken code after rename. If possible, it would be best to have this location work for both init and typename in both directions.
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.
When renaming from the Foo
in Foo(x: 1)
, we translate the type name instead of initializer name; and that's in consistence with our intended behavior. I cannot think of a situation when we need such lenience when renaming from Swift side.
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.
Ignore my above comments, I think we have the similar situation in Swift as well.
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.
Is that something that changed in this commit, because it's not what I see right now. I see it trying to find the initializer name, which then causes us to change Foo
to fooWithX
in the ObjC code.
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.
You are right. We need to add the similar logic to handle swift->objc translation as well.
@swift-ci please smoke test |
@benlangmuir mind taking another look? |
LGTM, thanks! |
When translating objc names to swift names, if the given name is not an objc
function name, and the cursor points to a constructor call, we use the type
declaration instead of the init declaration to translate.