Skip to content

[CodeCompletion] Map the result type for keypath member lookup #25717

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 24, 2019

struct Circle {
  var center: Point { get }
  var radius: Length { get }
}

@dynamicMemberLookup
struct Wrapper<T> {
  subscript<U>(dynamicMember: KeyPath<T, U>) -> Wrapped<U> { get }
}

func test(value: Wrapper<Circle>) {
  value.#HERE#
}

The type of center and radius should be Wrapped<Point> and Wrapped<Length> respectively.

rdar://problem/50073837

NOTE: This implementation doesn't properly handle:

  • Nested wrapper
    (e.g. Wrapper<Wrapper<Point>>)
  • Generic result type in KeyPath
    (e.g. subscript<U>(dynamicMember: KeyPath<T, Box<U>>) -> Wrapper<U>)

@rintaro rintaro requested review from xedin and DougGregor June 24, 2019 19:18
@rintaro
Copy link
Member Author

rintaro commented Jun 24, 2019

@xedin, @DougGregor Could you check I'm doing right thing?

@rintaro rintaro requested a review from benlangmuir June 24, 2019 19:20
@rintaro rintaro force-pushed the ide-completion-keypathlookup-rdar50073837 branch from 5b426f4 to 38f51b4 Compare June 24, 2019 19:30
@rintaro rintaro force-pushed the ide-completion-keypathlookup-rdar50073837 branch from 38f51b4 to 9f02fa7 Compare June 24, 2019 19:34
@rintaro
Copy link
Member Author

rintaro commented Jun 24, 2019

@swift-ci Please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me, thanks Rintaro!

@rintaro rintaro merged commit e7c8e22 into swiftlang:master Jun 24, 2019
@rintaro rintaro deleted the ide-completion-keypathlookup-rdar50073837 branch June 24, 2019 21:49
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.

3 participants