swiftlang / swiftlang/sourcekit-lsp
[SR-13653] SourceKit-LSP: show full type signature in autocompletion
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.9k
- Forks
- 390
- Avg merge
- 9d 5h
- Merged PRs (30d)
- 3
Description
| Previous ID | SR-13653 |
| Radar | rdar://problem/69958775 |
| Original Reporter | @xAlien95 |
| Type | Improvement |
Attachment: Download
Additional Detail from JIRA
| Votes | 0 |
| Component/s | SourceKit-LSP |
| Labels | Improvement |
| Assignee | None |
| Priority | Medium |
md5: 082a2c11b6e53a2c078c70bdfa52294a
Issue Description:
Currently, when typing max you get
max(_ x: Comparable, _ y: Comparable) -> Comparable
as a suggested type signature, which may led the user into thinking that the function accepts existential protocol types instead of a unique type "T: Comparable" in both the arguments and result (see attached image, P1 and P2 are protocols, C1 is a class).
It may be more useful to show
max<T: Comparable>(_ x: T, _ y: T) -> T
as suggested type signature, although less readable.
We have the same issue when typing in the function body:
protocol SomeProtocol {}
class SomeClass {}
func foo<T: Collection>(_ x: T) {
x // suggested as "x: Collection" instead of "x: T"
}
func bar<T: SomeClass & SomeProtocol>(_ x: T) {
x // suggested as "x: SomeProtocol" instead of "x: T"
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Swift completion examples for max, foo, and bar in SourceKit-LSP, then trace the completion path that formats displayed type signatures. Compare the current existential-style output with the generic signatures described here; done means completions preserve the type parameter and its constraints in both function declarations and local values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100