-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[code-completion] Add type context for single-expression function bodies #23587
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
Extend the support for single-expression closures to handle single-expression functions of all kinds. This allows, e.g. func foo() -> MyEnum { .<here> } to complete members of `MyEnum`.
This adds an implicit body so that we can dig out the return type context the same way as a normal function. For now, we are also treating the first expression in a multi-statement implicit getter body the same way; we'll need to refactor how we complete in accessors to differentiate those cases.
@swift-ci please test |
@nate-chandler FYI this PR adds code-completion support for your "allow return to be omitted" change. The implementation doesn't require your changes so far, so I've left it a separate PR to make it easier to review. |
@rintaro I added the tests for init, deinit, and top-level vars. I was wrong about handling init?() { #^A^# } This case gets |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please smoke test |
Extend the support for single-expression closures to handle single-expression functions of all kinds. This allows, e.g.
to complete members of
MyEnum
.rdar://problem/48938531
Note: this conceptually depends on #23251, which implements the language feature