Could you clarify why this is a language feature rather than, say, a SourceKit feature? Say something along the lines of:
- You type a leading dot at an argument position where the type is generic.
- If there are no protocol requirements, SourceKit does nothing.
- If there are protocol requirements, SourceKit looks up which types are declared to conform to protocol requirements and pass on the list to the editor for completion.
- When a completion is chosen, the editor deletes the previous dot and inserts the selected type.
I'm reading through the comments here and re-reading the proposal, and it seems like all of the discussion is focused on describing how we could make this work as a language feature. As I understand it, the primary benefit is in helping someone write code [speaking as someone who just started learning SwiftUI last week and hit this issue of "wait what do I put here???"], and the benefit for readability is not that big (IMO).
Implementing this as a SourceKit feature has three benefits:
- We don't need to change the language. If people still feel that this really impairs readability, then we can revisit the issue at a later stage.
- It avoids the weird edge cases that other people have pointed out, such as this one.
func squared<T: FixedWidthInteger>(_ x: T) -> T? { ... } let squaredBitWidth = squared(.bitWidth) // picks T == Int - Library maintainers don't have the additional burden of such similar static members for protocols they are vending.