-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completionArea → source tooling: code completioncompilerThe Swift compiler itselfThe Swift compiler itselfsource toolingArea: IDE support, SourceKit, and other source toolingArea: IDE support, SourceKit, and other source tooling
Description
Previous ID | SR-13426 |
Radar | None |
Original Reporter | @LucianoPAlmeida |
Type | Bug |
Status | Closed |
Resolution | Done |
Attachment: Download
Environment
Xcode 12 Beta 1 Swift 5.3
Additional Detail from JIRA
Votes | 0 |
Component/s | CodeCompletion, Compiler |
Labels | Bug |
Assignee | @LucianoPAlmeida |
Priority | Medium |
md5: a1df7824b85ed7ba81bc9ad88e92c0eb
Issue Description:
When having a contextual key path type with an optional root
struct A {
var property: String
}
let keyPath: KeyPath<A?, String> = \.#^COMPLETION^#
Code completion gives those options

And when selecting a property, the inserted code is invalid

Because `?.property` is not acceptable since inferring key path root type as an optional is not supported. The problem is that we also cannot`.property` because it would not be able to convert the inferred non-optional root to the optional contextual root.
So I'm not sure what would be a solution to this, maybe not allow declarations of a key path with optional root...
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completionArea → source tooling: code completioncompilerThe Swift compiler itselfThe Swift compiler itselfsource toolingArea: IDE support, SourceKit, and other source toolingArea: IDE support, SourceKit, and other source tooling