swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.09k stars 10.33k forks source link

Result builder dynamic key path autocomplete breaks for second component #69477

Open stephencelis opened 9 months ago

stephencelis commented 9 months ago

Description

I have a project with a decently complex builder that works with objects that can be configured with key paths but am finding that only the first builder expression can autocomplete correctly. In general autocomplete is struggling with these expressions.

Steps to reproduce

  1. Clone https://github.com/pointfreeco/swift-composable-architecture

  2. Check out the case-key-paths branch (HEAD at 63ed79606882de385e22afcdf847e46277142b07 at the time of submitting this issue)

  3. Open ComposableArchitecture.xcworkspace

  4. Select "CaseStudies (SwiftUI)" build scheme

  5. Build

  6. Navigate to https://github.com/pointfreeco/swift-composable-architecture/blob/63ed79606882de385e22afcdf847e46277142b07/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Composition-TwoCounters.swift#L25

  7. Autocomplete action: \. from line 25, note:

    image
  8. Autocomplete action: \. from line 28, note:

    image

Bonus bug:

Expected behavior

I expect autocomplete to work.

Environment

stephencelis commented 9 months ago

/cc @xedin

Please let me know if I'm missing something in the project's result builder that could address these usability issues.

stephencelis commented 9 months ago

This seems to be an order of operation of builder type checking vs. macro expansion. If I explicitly add : Reducer (in addition to the @Reducer macro) this restores the above action: autocomplete and others, though there are complex situations, like Reduce { state, action in … } blocks in which state. and switch action { case . do not autocomplete till generics are qualified, e.g., Reduce<State, Action> { state, action in