Add support for conditionally compiled endpoints#430
Open
fruitcoder wants to merge 1 commit intopointfreeco:mainfrom
Open
Add support for conditionally compiled endpoints#430fruitcoder wants to merge 1 commit intopointfreeco:mainfrom
fruitcoder wants to merge 1 commit intopointfreeco:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support conditionally compiled endpoints in
@DependencyClientPreviously,
@DependencyClientonly recognized endpoints declared directly in the struct body. Endpoints wrapped in#if/#endifblocks were silently ignored — no@DependencyEndpointwas applied, and the generated member-wise initializer made no attempt to initialize them.What changed
DependencyClientMacronow handlesIfConfigDeclSyntaxduring member iteration. Each#ifclause is collected into aConditionalGroup(keyed by its condition string, e.g.os(iOS)), and its properties are processed with the same logic as unconditional members.Initializer generation is updated to account for conditional endpoints:
#if-wrapped init whose parameters include both the unconditional endpoints and that group's endpoints.#if-guarded body block that assigns an unimplemented closure to each conditional endpoint it doesn't take as a parameter, so Swift's definite initialization is satisfied on all platforms.For example:
expands to three inits:
Unimplemented closures delegate to
DependencyEndpointMacrorather than being hand-rolled.unimplementedAssignment(for:)callsDependencyEndpointMacro.expansion(of:providingPeersOf:in:)and extracts the initializer from the generated _property peer, so the closure is always in sync with what@DependencyEndpointitself produces (including the\(Self.self)dynamic type name in the issue message).