Skip to content
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

Enum reducers: generate direct action cases for ephemeral state #3240

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

stephencelis
Copy link
Member

Currently, the following reducer enum:

@Reducer
enum Destination {
  case alert(AlertState<Never>)
}

Generates the following action:

@CasePathable
enum Action {
  case alert(AlertState<Never>.Action)
}

And this produces a warning in Case Paths 1.5 due to the nested Never not being referenced directly.

This PR plucks the action type out and embeds it directly, instead:

-case alert(AlertState<Never>.Action)
+case alert(Never)

Which will allow us to better suppress warnings Swift emits for uninhabited types.

Currently, the following reducer enum:

```swift
@Reducer
enum Destination {
  case alert(AlertState<Never>)
}
```

Generates the following action:

```swift
@CasePathable
enum Action {
  case alert(AlertState<Never>.Action)
}
```

And this produces a warning in Case Paths 1.5 due to the nested `Never`
not being referenced directly.

This PR plucks the action type out and embeds it directly, instead:

```diff
-case alert(AlertState<Never>.Action)
+case alert(Never)
```

Which will allow us to better suppress warnings Swift emits for
uninhabited types.
@stephencelis stephencelis merged commit 146218a into main Jul 16, 2024
7 checks passed
@stephencelis stephencelis deleted the alert-state-macro-fixes branch July 16, 2024 23:39
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.

2 participants