-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IDE] Two more preparation commits for solver-based cursor info #62359
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
[IDE] Two more preparation commits for solver-based cursor info #62359
Conversation
@swift-ci Please smoke test |
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.
Not sure how you're planning on using isDynamicRef
, but sure 👍
@@ -746,6 +746,19 @@ struct SelectedOverload { | |||
const Type boundType; | |||
}; | |||
|
|||
/// Information that \c getSelectedOverloadInfo gathered about a | |||
/// \c SelectedOverload. | |||
struct SelectedOverloadInfo { |
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.
We have a representation for this already - SelectedOverload
- it has all of the types plus OverloadChoice
which would give you base type and kind, why not use that directly?
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.
The computation of SelectedOverloadInfo
is using SelectedOverload
under the hood but we need to do some more adjustments of key path overloads to get the behavior we need for code completion (see implementation of getSelectedOverloadInfo
). In particular in the case of KeyPathDynamicMemberLookup
we don’t return information for the subscript(keyPath:)
declaration but for the key path member access itself. This requires forming a new constraint locator (https://github.com/apple/swift/pull/62359/files#diff-d57f6f2d466f1f207cdf2dbd0396a1dbb2caba7b6828ebdb9954948f0ac2b499R3876-R3891).
AFAICT we have the following options:
- Store the types that
SelectedOverloadInfo
contains inSelectedOverload
. I don’t really like the idea because the information seems to be IDE-specific to me and not useful for general type checking. - Add methods to
SelectedOverload
that compute the types stored inSelectedOverloadInfo
. I don’t like this approach since the computation ofCallBaseTy
andFuncTy
require theSolution
in which the overload was picked as well as theContraintLocator
that referred to it. - Name
SelectedOverloadInfo
something more IDE-specific - Move
getSelectedOverloadInfo
intolibIDE
(where it essentially came from, previously it was a static function in ArgumentCompletion.cpp)
I think I like the last option best. WDYT @xedin?
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 concur, let's move that functionally to libIDE and feed it information from SelectedOverload
.
We will need this for solver-based cursor info.
This allows isDynamicRef to work with types from a constraint system solution
…tem produces a solution When doing solver-based cursor info, we’ll type check the expression in question using a normal `typeCheckASTNodeAtLoc` call (not in code completion mode) and listen for any solutions that were produced during the type check.
35985e4
to
4b62682
Compare
@swift-ci Please smoke test |
[IDE] Make isDynamicRef take a
getType
function (@bnbarham)This allows isDynamicRef to work with types from a constraint system solution
[IDE] Move getSelectedOverloadInfo to be a function on Solution (@xedin)
We will need this for solver-based cursor info.
[Sema] Add a solution callback that is called when the constraint system produces a solution (@xedin)
When doing solver-based cursor info, we’ll type check the expression in question using a normal
typeCheckASTNodeAtLoc
call (not in code completion mode) and listen for any solutions that were produced during the type check.