-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Force print '!' for optional method call in code completion. #16910
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
[SourceKit] Force print '!' for optional method call in code completion. #16910
Conversation
@swift-ci Please smoke test |
@benlangmuir Could you take a look? I'm not 100% sure this fix is OK. |
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.
Yeah I think making it optional (with optional typename) would be better.
@@ -0,0 +1,13 @@ | |||
import Foundation |
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 this really necessary in a test? I don't think most of our tests with @objc are importing Foundation.
} | ||
if (!C.isAnnotation() && C.hasText()) { | ||
case ChunkKind::OptionalMethodCallTail: |
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 make the chunk not an annotation? Then it would be handled by the simple case below. Generally annotation chunks should be skipped.
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 kept it isAnnotation()
to prevent key.name
to have !
in it. I'll try to modify key.name
generation instead.
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.
Yeah, that would be better. It wouldn't be the end of the world if the ! or ? ended up in the name either.
a8cbd3e
to
7fdfe7a
Compare
@swift-ci Please smoke test |
We decided not to make it optional typename. It's consistent with the behavior for optional chain. |
Calling '@objc optional func' requires '?' or '!' after its name. When completing method calls for them, 'key.sourcetext' should have '?' whereas 'key.name' shouldn't. Note that we deliberately do not use optional type name for 'key.typename'. This is consistent with optional chain '?.<propertyName>' behavior. rdar://problem/37904574
7fdfe7a
to
e159a06
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
…on. (swiftlang#16910) Calling '@objc optional func' requires '?' or '!' after its name. When completing method calls for them, 'key.sourcetext' should have '?' whereas 'key.name' shouldn't. Note that we deliberately do not use optional type name for 'key.typename'. This is consistent with optional chain '?.<propertyName>' behavior. rdar://problem/37904574
Calling
@objc optional func
requires?
or!
after its name. When completing method calls for them,key.sourcetext
should have!
whereaskey.name
shouldn't.Previously,
completing at
<HERE>
used to completebar()
(without!
).rdar://problem/37904574