Skip to content

Integrate CasePaths trait#220

Open
vladyslavsosiuk wants to merge 2 commits into
pointfreeco:mainfrom
vladyslavsosiuk:feat/case-paths-trait-integration
Open

Integrate CasePaths trait#220
vladyslavsosiuk wants to merge 2 commits into
pointfreeco:mainfrom
vladyslavsosiuk:feat/case-paths-trait-integration

Conversation

@vladyslavsosiuk

@vladyslavsosiuk vladyslavsosiuk commented Jun 12, 2026

Copy link
Copy Markdown

Based on slack discussion:
https://pointfreecommunity.slack.com/archives/C04L2D8PN4D/p1781144641623609

With the recent soundness hole fix in Swift it is no longer possible to derive a Shared "view" into an enum's case:

  @CasePathable
  @dynamicMemberLookup
  enum Route: Equatable {
    case detail(Int)
    case settings
  }

  struct Model: Equatable {
    var route: Route
  }
  
  @Shared(value: Model(route: .detail(42))) var model
   let sharedDetail = Shared($model.route.detail) // Cannot assign through dynamic lookup property: '$model' is immutable

This PR implements an approach similar to https://github.com/pointfreeco/swift-navigation/blob/7d1f9d77cf4eacde94c8ffa19fe6ba6a9c37bdb7/Sources/SwiftNavigation/UIBinding.swift#L412-L428 that allows to derive a "view" into enum case and it even let's one avoid wrapping in a Shared.init(_):

@Shared(value: Model(route: .detail(1))) var model
 let sharedDetail = $model.route.detail

@vladyslavsosiuk vladyslavsosiuk force-pushed the feat/case-paths-trait-integration branch from e6011ff to 2ba62d8 Compare June 12, 2026 15:39
@vladyslavsosiuk vladyslavsosiuk force-pushed the feat/case-paths-trait-integration branch from 2ba62d8 to 8a755c9 Compare June 12, 2026 19:58
@vladyslavsosiuk vladyslavsosiuk marked this pull request as ready for review June 12, 2026 20:18
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.

1 participant