Skip to content

[CodeCompletion][Sema] Refine logic that ignores missing arguments after the code completion position when solving #35136

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

nathawes
Copy link
Contributor

@nathawes nathawes commented Dec 17, 2020

If the completion loc was in a trailing closure arg, it only makes sense to ignore later missing args if they can accept a closure argument (e.g. function type, Any, or generics), as there's no way for the user to complete the call for the overload being matched otherwise.

This also fix a bug where we were incorrectly penalizing solutions with holes that were ultimately due to missing arguments after the completion position (e.g. if the missing argument corresponded to a generic parameter), and ended up excluding those solutions from the results.

Resolves rdar://problem/72412302

@nathawes nathawes requested review from xedin and rintaro December 17, 2020 05:47
@nathawes
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable.

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I have left a couple of comments inline.

@nathawes nathawes force-pushed the dont-allow-missing-args-if-trailing-and-not-function-type branch from 1ca0d69 to c9fe157 Compare February 19, 2021 06:34
@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes nathawes force-pushed the dont-allow-missing-args-if-trailing-and-not-function-type branch from c9fe157 to eefdce5 Compare February 19, 2021 07:00
@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes nathawes requested a review from xedin February 19, 2021 07:04
…ter the code completion position when solving

If the completion loc was in a trailing closure arg, it only makes sense to
ignore later missing args if they have function type, as there's no way for the
user to complete the call for overload being matched otherwise.

Also fix a bug where we were incorrectly penalizing solutions with holes that
were ultimately due to missing arguments after the completion position.

Resolves rdar://problem/72412302
@nathawes nathawes force-pushed the dont-allow-missing-args-if-trailing-and-not-function-type branch from eefdce5 to cdcaa11 Compare February 19, 2021 23:00
@nathawes
Copy link
Contributor Author

@swift-ci please test and merge

@nathawes
Copy link
Contributor Author

@swift-ci please test and merge

@swift-ci swift-ci merged commit bd0d3ac into swiftlang:main Feb 23, 2021
@nathawes nathawes deleted the dont-allow-missing-args-if-trailing-and-not-function-type branch February 23, 2021 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants