Skip to content

Enabled ExistentialAny setting#5

Merged
NSFatalError merged 2 commits intomainfrom
chore/review
Apr 24, 2025
Merged

Enabled ExistentialAny setting#5
NSFatalError merged 2 commits intomainfrom
chore/review

Conversation

@NSFatalError
Copy link
Copy Markdown
Owner

@NSFatalError NSFatalError commented Apr 24, 2025

Summary by CodeRabbit

  • New Features

    • All targets now compile with Swift language mode version 6 and enable the upcoming "ExistentialAny" feature.
  • Refactor

    • Updated various protocol and property types to use Swift's explicit existential any keyword for improved type abstraction and flexibility.
    • Adjusted package dependencies to use a different module.
  • Style

    • Modernized method and property signatures to align with newer Swift syntax conventions.

@NSFatalError NSFatalError self-assigned this Apr 24, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2025

Walkthrough

This update introduces explicit usage of Swift's existential any keyword throughout protocol type annotations and method signatures in the codebase. Several protocol properties and method parameters now use any to clarify existential types, aligning with modern Swift syntax. Compiler settings are updated in the package manifest to enable Swift 6 mode and the "ExistentialAny" feature for all targets. Additionally, some package dependencies and import statements are updated, notably switching from "Principle" to "PrincipleCollections" where relevant. No logic or control flow changes are present; all updates focus on type annotations and build configuration.

Changes

File(s) Change Summary
Package.swift Changed dependency for "PrincipleMacros" from "Principle" to "PrincipleCollections". Added a configuration block to apply Swift 6 language mode and enable "ExistentialAny" for all targets.
Sources/PrincipleMacros/Builders/Declarations/Common/DeclBuilder.swift Changed basicDeclaration property type in DeclBuilder protocol from BasicDeclSyntax to any BasicDeclSyntax.
Sources/PrincipleMacros/Builders/Declarations/Members/PropertyDeclBuilder.swift Updated basicDeclaration property return type in PropertyDeclBuilder extension from BasicDeclSyntax to any BasicDeclSyntax.
Sources/PrincipleMacros/Builders/Declarations/Types/ClassDeclBuilder.swift Changed typeDeclaration property return type in ClassDeclBuilder extension from TypeDeclSyntax to any TypeDeclSyntax.
Sources/PrincipleMacros/Builders/Declarations/Types/EnumDeclBuilder.swift Changed typeDeclaration property return type in EnumDeclBuilder extension from TypeDeclSyntax to any TypeDeclSyntax.
Sources/PrincipleMacros/Builders/Declarations/Types/StatefulDeclBuilder.swift Changed declaration property type in StatefulDeclBuilder protocol from StatefulDeclSyntax to any StatefulDeclSyntax. Changed typeDeclaration in extension from TypeDeclSyntax to any TypeDeclSyntax.
Sources/PrincipleMacros/Builders/Declarations/Types/StructDeclBuilder.swift Changed typeDeclaration property return type in StructDeclBuilder extension from TypeDeclSyntax to any TypeDeclSyntax.
Sources/PrincipleMacros/Builders/Declarations/Types/TypeDeclBuilder.swift Changed typeDeclaration property in TypeDeclBuilder protocol from TypeDeclSyntax to any TypeDeclSyntax. Changed basicDeclaration in extension from BasicDeclSyntax to any BasicDeclSyntax.
Sources/PrincipleMacros/Parsers/Common/Parser.swift Updated Parser protocol method signatures to use any DeclSyntaxProtocol and any MacroExpansionContext for parameter types.
Sources/PrincipleMacros/Parsers/Common/_Parser.swift Changed context parameter type in _Parser extension's parse method from MacroExpansionContext to any MacroExpansionContext.
Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift Changed parameters in EnumCasesParser.parse from DeclSyntaxProtocol and MacroExpansionContext to any DeclSyntaxProtocol and any MacroExpansionContext.
Sources/PrincipleMacros/Parsers/Properties/PropertiesList.swift Changed import from Principle to PrincipleCollections.
Sources/PrincipleMacros/Parsers/Properties/PropertiesParser.swift Changed parameters in PropertiesParser.parse from DeclSyntaxProtocol and MacroExpansionContext to any DeclSyntaxProtocol and any MacroExpansionContext.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Parser
    participant MacroExpansionContext

    Client->>Parser: parse(declaration: any DeclSyntaxProtocol, in: any MacroExpansionContext)
    Parser->>MacroExpansionContext: (uses context methods)
    Parser-->>Client: ResultsCollection / PropertiesList / EnumCasesList
Loading

Poem

In the warren of code, the rabbits all cheer,
For “any” is here—existentials are clear!
Swift 6 is enabled, the settings are set,
With macros and parsers, our best code yet.
Dependencies shuffled, imports align,
The burrow is modern—oh, how we shine!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3c3d13 and 0e89bc9.

📒 Files selected for processing (13)
  • Package.swift (2 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Common/DeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Members/PropertyDeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Types/ClassDeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Types/EnumDeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Types/StatefulDeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Types/StructDeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Builders/Declarations/Types/TypeDeclBuilder.swift (1 hunks)
  • Sources/PrincipleMacros/Parsers/Common/Parser.swift (1 hunks)
  • Sources/PrincipleMacros/Parsers/Common/_Parser.swift (1 hunks)
  • Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift (1 hunks)
  • Sources/PrincipleMacros/Parsers/Properties/PropertiesList.swift (1 hunks)
  • Sources/PrincipleMacros/Parsers/Properties/PropertiesParser.swift (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Sources/PrincipleMacros/Parsers/Common/Parser.swift (3)
Sources/PrincipleMacros/Parsers/Common/_Parser.swift (1)
  • parse (17-26)
Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift (1)
  • parse (14-27)
Sources/PrincipleMacros/Parsers/Properties/PropertiesParser.swift (1)
  • parse (14-48)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build-and-test (watchos)
  • GitHub Check: build-and-test (visionos)
  • GitHub Check: build-and-test (macos)
  • GitHub Check: build-and-test (ios)
  • GitHub Check: build-and-test (maccatalyst)
🔇 Additional comments (17)
Package.swift (2)

41-41: Dependency name updated correctly

The dependency has been updated from "Principle" to "PrincipleCollections", which aligns with the import changes in other files.


67-72: Swift compiler settings properly enabled

Adding Swift language mode v6 and enabling the "ExistentialAny" feature at the package level is a good approach. This ensures consistent language features across all targets and supports the explicit any keyword usage for existential types throughout the codebase.

Sources/PrincipleMacros/Parsers/Properties/PropertiesList.swift (1)

10-10: Import updated correctly

The import has been updated from "Principle" to "PrincipleCollections", matching the dependency change in Package.swift.

Sources/PrincipleMacros/Builders/Declarations/Members/PropertyDeclBuilder.swift (1)

18-18: Existential type properly annotated

The return type has been correctly updated to use the any keyword with BasicDeclSyntax, making the existential type usage explicit. This improves type clarity and aligns with Swift's evolution direction.

Sources/PrincipleMacros/Builders/Declarations/Common/DeclBuilder.swift (1)

13-13: Existential type properly annotated

The property type has been correctly updated to use the any keyword with BasicDeclSyntax, making the existential type usage explicit. This improves type clarity and aligns with Swift's evolution direction.

Sources/PrincipleMacros/Builders/Declarations/Types/EnumDeclBuilder.swift (1)

18-18: Correct implementation of any for existential type

This change correctly adds the explicit any keyword to the protocol type annotation, which is required for Swift 6 compatibility when using protocol types as existentials.

Sources/PrincipleMacros/Builders/Declarations/Types/StructDeclBuilder.swift (1)

18-18: Appropriate usage of explicit any for existential type

The addition of the any keyword before TypeDeclSyntax properly implements Swift 6's requirement for explicit existential types. This change is consistent with similar updates in sibling builder classes.

Sources/PrincipleMacros/Builders/Declarations/Types/ClassDeclBuilder.swift (1)

18-18: Well-implemented existential type annotation

The explicit any keyword has been correctly added to the protocol type, aligning with Swift language version 6 requirements for existential types and maintaining consistency with the other builder implementations.

Sources/PrincipleMacros/Builders/Declarations/Types/TypeDeclBuilder.swift (2)

13-13: Protocol requirement correctly updated with any

The protocol requirement has been properly updated to use the explicit any keyword for the TypeDeclSyntax existential type, conforming to Swift 6 standards.


18-18: Consistent application of any keyword

The basicDeclaration property has been correctly updated with the any keyword for its existential type, maintaining consistency with the other changes in this PR.

Sources/PrincipleMacros/Parsers/Common/_Parser.swift (1)

19-19: LGTM! Nice adoption of Swift's explicit existential syntax.

Using any MacroExpansionContext instead of just MacroExpansionContext explicitly indicates this is an existential type, aligning with Swift's evolution toward requiring explicit annotation of protocol types. This future-proofs your code for upcoming Swift language requirements.

Sources/PrincipleMacros/Builders/Declarations/Types/StatefulDeclBuilder.swift (2)

13-13: LGTM! Well-implemented existential type annotation.

Properly updated protocol property to use any StatefulDeclSyntax instead of just StatefulDeclSyntax, making it clear this is an existential type rather than a concrete type.


18-18: LGTM! Good consistency with existential syntax.

Correctly updated the computed property return type to any TypeDeclSyntax, matching the pattern used throughout the codebase and maintaining consistency with the Swift 6 mode enabled in the package.

Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift (1)

15-16: LGTM! Appropriate use of explicit existentials in method parameters.

Both parameters have been correctly updated to use the any keyword for protocol types, which improves code clarity and aligns with Swift's direction toward requiring explicit annotation of existential types.

Sources/PrincipleMacros/Parsers/Properties/PropertiesParser.swift (1)

15-16: LGTM! Consistent application of existential type syntax.

The parameter types have been appropriately updated to use the any keyword, maintaining consistency with the rest of the codebase and preparing for Swift's future requirements around explicit existentials.

Sources/PrincipleMacros/Parsers/Common/Parser.swift (2)

17-19: Use of any clarifies existential protocol parameters
Explicitly annotating declaration and context as any DeclSyntaxProtocol and any MacroExpansionContext improves readability and aligns with Swift 6’s ExistentialAny requirement. This change matches the updated syntax in other parsers and has no impact on runtime behavior.


22-24: Maintain consistency for existential context parameter
Adding any before MacroExpansionContext here ensures uniform use of explicit existential types across all parse overloads and prevents implicit existential warnings under Swift 6 mode.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@NSFatalError NSFatalError merged commit 8a999b2 into main Apr 24, 2025
8 checks passed
@NSFatalError NSFatalError deleted the chore/review branch April 24, 2025 13:14
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