-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[CursorInfo] Implement a few expression references as solver-based #62478
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
Merged
ahoppen
merged 5 commits into
swiftlang:main
from
ahoppen:ahoppen/solver-based-cursor-info
Feb 10, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6ee695a
[CursorInfo] Implement a few expression references as solver-based
ahoppen fcc5d98
[CursorInfo] Deliver results from solver-based cursor info
ahoppen e7ee839
[CursorInfo] A few miscellaneous fixes to the AST-based cursor info a…
ahoppen 3e46063
[CursorInfo] Fix bug when performing solver-based cursor info on Self
ahoppen a9cba54
[CursorInfo] Fix a bug that caused solver-based cursor info to crash …
ahoppen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| func test() { | ||
| // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s | ||
| Swift.min(1, 2) | ||
| } | ||
|
|
||
| // CHECK: source.lang.swift.ref.function.free () | ||
| // CHECK-NEXT: min(_:_:) | ||
| // CHECK-NEXT: s:s3minyxx_xtSLRzlF | ||
| // CHECK-NEXT: source.lang.swift | ||
| // CHECK-NEXT: <T where T : Comparable> (T, T) -> T | ||
| // CHECK-NEXT: $syxx_xtcSLRzluD | ||
| // CHECK-NEXT: Swift |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| protocol Publisher<Output> { | ||
| associatedtype Output | ||
| } | ||
|
|
||
| extension Publisher { | ||
| func stage2() -> MyGenerictype<Self.Output> { | ||
| fatalError() | ||
| } | ||
|
|
||
| func stage3() -> Self { | ||
| fatalError() | ||
| } | ||
| } | ||
|
|
||
| struct MyGenerictype<Output> : Publisher { | ||
| init() {} | ||
|
|
||
| func stage1(with output: Self.Output) -> HasTypeAccessInTypealias<Self> { | ||
| fatalError() | ||
| } | ||
| } | ||
|
|
||
| struct HasTypeAccessInTypealias<Upstream> : Publisher where Upstream : Publisher { | ||
| typealias Output = Upstream.Output | ||
| } | ||
|
|
||
| func test() { | ||
| MyGenerictype() | ||
| .stage1(with: 0) | ||
| .stage2() | ||
| // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):6 %s -- %s | ||
| .stage3() | ||
| } | ||
|
|
||
| // CHECK: <Declaration>func stage3() -> <Type usr="s:4test13MyGenerictypeV">MyGenerictype</Type><<Type usr="s:4test24HasTypeAccessInTypealiasV">HasTypeAccessInTypealias</Type><<Type usr="s:4test13MyGenerictypeV">MyGenerictype</Type><<Type usr="s:Si">Int</Type>>>.<Type usr="s:4test24HasTypeAccessInTypealiasV6Outputa">Output</Type>></Declaration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| class UserCollection { | ||
| static let staticMember = "ABC" | ||
| func test() { | ||
| // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):10 %s -- %s | ||
| Self.staticMember | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 there more to delivering them then just adding a loop here?
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.
All the results are reported using callback functions because they have pointers to stack variables – which they really shouldn’t have but that’s something else I want to fix. Thus, we cannot store the results, run the AST-based cursor info and then report them. Hence, what we do right now is serialize the results into a string and just deliver the AST-based results.
So: Delivering the results is a non-trivial change that I want to do in a follow-up PR, especially since we want to fall back to AST-based cursor info if solver-based cursor info doesn’t return any results.
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.
OK, I changed my mind and changed this PR to also deliver the solver-based results. The stress tester found too many (~100) differences between solver-based and AST-based cursor info and in in all of them the solver-based result was superior. So, apparently the verification has outgrown its usefulness and we should just use the solver-based results.
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.
To be clear, we're now only delivering the one result right 😅?
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.
Yes, for now. Fixing the
TODOin the line above is the next thing to do.// FIXME: We need to be able to report multiple results.