Skip to content

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Aug 31, 2025

When doing code completion it's entirely expected we'll end up with ambiguities in the body of a closure if we're completing e.g someOverloadedFn(#^CC^#). As such we don't want to penalize the solution for unbound type variables outside of the body since that will prevent us from being able to eagerly prune e.g disfavored overloads in the outer scope. This gives up to a 7% perf win in the stress tester.

@hamishknight
Copy link
Contributor Author

@swift-ci please SourceKit stress test

When doing code completion it's entirely expected we'll end up with 
ambiguities in the body of a closure if we're completing e.g
`someOverloadedFn(#^CC^#)`. As such we don't want to penalize the
solution for unbound type variables outside of the body since that 
will prevent us from being able to eagerly prune e.g disfavored
overloads in the outer scope. This gives up to a 7% perf win in the
stress tester.
@hamishknight hamishknight changed the title [DNM] Experiment: Avoid increasing score for unbound type vars for completion [CS] Avoid increasing score for unbound outer type vars for completion Sep 1, 2025
@hamishknight
Copy link
Contributor Author

@swift-ci please smoke test

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.

Makes sense, thank you!

@xedin
Copy link
Contributor

xedin commented Sep 1, 2025

@hamishknight one more thing we can do to improve ranking is to checking whether arguments had any holes or fixes associated with them before ranking overloads, I don’t think it makes sense to rank choices that got fixed since the assumption in the ranking is that everything was matched correctly.

@hamishknight
Copy link
Contributor Author

@xedin Assuming I understand you correctly, I think we should already handle that case, we check isArgumentIgnoredForCodeCompletion before recording a fix or binding a hole and avoid increasing the score for such arguments

@bnbarham bnbarham merged commit 52b2871 into swiftlang:main Sep 2, 2025
3 checks passed
@hamishknight hamishknight deleted the pothole branch September 2, 2025 16:32
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.

3 participants