Skip to content

[CodeCompletion] Do not offer completion Wrapped members for optional key path root type #33601

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

Conversation

LucianoPAlmeida
Copy link
Contributor

As described on the SR code completion is offering wrapped member for optional root key path type, which leads to invalid completions in some situations because using key path optional root to access wrapped members is invalid.

Resolves SR-13426.

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please test

@LucianoPAlmeida
Copy link
Contributor Author

cc @varungandhi-apple :)

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 919db68b36617ffffaad15fea3ecd042e69bd086

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please test MacOS platform

@rintaro
Copy link
Member

rintaro commented Aug 24, 2020

I think what we need to do is not removing . before ?.. The following example successfully compiles:

struct MyStruct {
  var value: Int { 1 }
}

func foo<T>(x: KeyPath<MyStruct?, T>) {}

let _ = foo(x: \.?.value)
let _ = foo(x: \MyStruct?.?.value)

@varungandhi-apple
Copy link
Contributor

TIL \.?.value is legal syntax.

@theblixguy
Copy link
Collaborator

TIL as well. It looks like the grammar mentions it: https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#grammar_key-path-components.

@LucianoPAlmeida
Copy link
Contributor Author

TIL \.?.value is legal syntax.

I also didn't known this

Thanks @rintaro, I'll make the changes :)

@LucianoPAlmeida
Copy link
Contributor Author

Changes applied to not erase the . for key path optional root type so completion will result in \.?.wrappedTypeMember
cc @rintaro

@LucianoPAlmeida LucianoPAlmeida force-pushed the SR-13426-code-completion-keypath-optional branch from 54c58f1 to 56f212f Compare September 1, 2020 00:52
@LucianoPAlmeida LucianoPAlmeida force-pushed the SR-13426-code-completion-keypath-optional branch from 56f212f to ecc5b90 Compare September 1, 2020 15:33
@rintaro
Copy link
Member

rintaro commented Sep 1, 2020

@swift-ci Please smoke test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@rintaro rintaro merged commit 679aaca into swiftlang:master Sep 1, 2020
@LucianoPAlmeida LucianoPAlmeida deleted the SR-13426-code-completion-keypath-optional branch September 1, 2020 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants