Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0d9af5d
-
NSFatalError Nov 21, 2025
d1012f1
-
NSFatalError Nov 21, 2025
c0cdfaf
[SwiftFormat] Applied formatting
NSFatalError Nov 21, 2025
5f93e9b
-
NSFatalError Nov 21, 2025
77acc75
-
NSFatalError Nov 21, 2025
0495316
-
NSFatalError Nov 21, 2025
b218f68
[SwiftFormat] Applied formatting
NSFatalError Nov 21, 2025
3823d0a
-
NSFatalError Nov 21, 2025
a9d5ff6
[SwiftFormat] Applied formatting
NSFatalError Nov 21, 2025
4d47af1
-
NSFatalError Nov 21, 2025
6f59de2
-
NSFatalError Nov 21, 2025
87bf3bd
-
NSFatalError Nov 21, 2025
b519312
-
NSFatalError Nov 21, 2025
ed34e2b
-
NSFatalError Nov 22, 2025
40f666c
-
NSFatalError Nov 22, 2025
600d256
[SwiftFormat] Applied formatting
NSFatalError Nov 22, 2025
2dc4d9b
-
NSFatalError Nov 22, 2025
d252434
-
NSFatalError Nov 22, 2025
a37ce11
[SwiftFormat] Applied formatting
NSFatalError Nov 22, 2025
39bedd1
-
NSFatalError Nov 22, 2025
58d9aa7
-
NSFatalError Nov 22, 2025
9d7a483
-
NSFatalError Nov 22, 2025
a7567a0
-
NSFatalError Nov 23, 2025
46b1776
-
NSFatalError Nov 23, 2025
ea7344a
-
NSFatalError Nov 23, 2025
cd74d85
-
NSFatalError Nov 23, 2025
8cf6797
-
NSFatalError Nov 23, 2025
b2ac2d1
-
NSFatalError Nov 23, 2025
514fa36
-
NSFatalError Nov 23, 2025
3e565d4
-
NSFatalError Nov 23, 2025
310be1b
-
NSFatalError Nov 23, 2025
cea794f
-
NSFatalError Nov 23, 2025
82a1709
-
NSFatalError Nov 23, 2025
c794584
-
NSFatalError Nov 23, 2025
dd5d1aa
-
NSFatalError Nov 23, 2025
4d647d5
-
NSFatalError Nov 23, 2025
bad8a9f
-
NSFatalError Nov 23, 2025
906bd5f
-
NSFatalError Nov 23, 2025
26a5f14
-
NSFatalError Nov 23, 2025
0f7a856
-
NSFatalError Nov 28, 2025
1f5fd7f
-
NSFatalError Nov 28, 2025
a1a517f
-
NSFatalError Nov 28, 2025
78f41cf
[SwiftFormat] Applied formatting
NSFatalError Nov 28, 2025
4715a6a
-
NSFatalError Nov 28, 2025
fef7ff9
-
NSFatalError Nov 28, 2025
b6753bb
-
NSFatalError Nov 28, 2025
2fb77b4
-
NSFatalError Nov 29, 2025
003b250
-
NSFatalError Nov 29, 2025
4d154d0
-
NSFatalError Nov 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: true

env:
XCODE_VERSION: "26.1"
XCODE_VERSION: "26.0"

jobs:
prepare:
Expand Down Expand Up @@ -88,16 +88,16 @@ jobs:
destination="platform=macOS,variant=Mac Catalyst"
;;
ios)
destination="platform=iOS Simulator,name=iPhone 17 Pro Max,OS=26.1"
destination="platform=iOS Simulator,name=iPhone 17 Pro Max,OS=26.0.1"
;;
tvos)
destination="platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=26.1"
destination="platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=26.0"
;;
watchos)
destination="platform=watchOS Simulator,name=Apple Watch Series 11 (46mm),OS=26.1"
destination="platform=watchOS Simulator,name=Apple Watch Series 11 (46mm),OS=26.0"
;;
visionos)
destination="platform=visionOS Simulator,name=Apple Vision Pro,OS=26.1"
destination="platform=visionOS Simulator,name=Apple Vision Pro,OS=26.0"
;;
*)
echo "Unknown platform: ${{ matrix.platform }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*'

env:
XCODE_VERSION: "26.1"
XCODE_VERSION: "26.0"

jobs:
release:
Expand Down
4 changes: 2 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ opt_in_rules:
- discouraged_assert
- discouraged_none_name
- discouraged_object_literal
- discouraged_optional_boolean
# discouraged_optional_boolean
- discouraged_optional_collection
- empty_collection_literal
- empty_count
Expand Down Expand Up @@ -67,7 +67,7 @@ opt_in_rules:
- local_doc_comment
- lower_acl_than_parent
# missing_docs
- modifier_order
# modifier_order
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public protocol DeclBuilder {

var preferredGlobalActorIsolation: GlobalActorIsolation? { get }
var preferredAccessControlLevel: AccessControlLevel? { get }
var maxAllowedAccessControlLevel: AccessControlLevel { get }

func build() throws -> [DeclSyntax]
}
Expand All @@ -34,7 +33,7 @@ extension DeclBuilder {
nil
}

public var maxAllowedAccessControlLevel: AccessControlLevel {
.public
public var inheritedAvailability: AttributeListSyntax? {
basicDeclaration.availability?.trimmed.withTrailingNewline
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ public protocol MemberBuilding {}
extension MemberBuilding where Self: TypeDeclBuilder {

public var inheritedAccessControlLevel: AccessControlLevel? {
.forMember(
of: typeDeclaration,
preferred: preferredAccessControlLevel
)
}

public var inheritedAccessControlLevelAllowingOpen: AccessControlLevel? {
.forMember(
of: typeDeclaration,
preferred: preferredAccessControlLevel,
maxAllowed: maxAllowedAccessControlLevel
maxAllowed: .open
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ public protocol PeerBuilding {}
extension PeerBuilding where Self: DeclBuilder {

public var inheritedAccessControlLevel: AccessControlLevel? {
.forPeer(
of: basicDeclaration,
preferred: preferredAccessControlLevel
)
}

public var inheritedAccessControlLevelAllowingOpen: AccessControlLevel? {
.forPeer(
of: basicDeclaration,
preferred: preferredAccessControlLevel,
maxAllowed: maxAllowedAccessControlLevel
maxAllowed: .open
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// PropertyDeclAccessorBuilder.swift
// PrincipleMacros
//
// Created by Kamil Strzelecki on 28/11/2025.
// Copyright © 2025 Kamil Strzelecki. All rights reserved.
//

import SwiftSyntaxMacros

public protocol PropertyDeclAccessorBuilder: PropertyDeclBuilder {

func buildAccessors() throws -> [AccessorDeclSyntax]
}

extension PropertyDeclAccessorBuilder {

public func build() throws -> [DeclSyntax] {
try buildAccessors().map(DeclSyntax.init)
}
Comment on lines +18 to +20
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find and examine the PropertyDeclAccessorBuilder file
fd -n "PropertyDeclAccessorBuilder.swift" -x cat -n {}

Repository: NSFatalError/PrincipleMacros

Length of output: 302


🏁 Script executed:

#!/bin/bash
# Search for the buildAccessors method definition
rg -n "buildAccessors" --type swift -B2 -A5

Repository: NSFatalError/PrincipleMacros

Length of output: 1348


🏁 Script executed:

#!/bin/bash
# Search for protocol or extension definitions related to PropertyDeclAccessorBuilder
rg -n "PropertyDeclAccessorBuilder|protocol.*Accessor|extension.*Accessor" --type swift -B2 -A10

Repository: NSFatalError/PrincipleMacros

Length of output: 3443


🏁 Script executed:

#!/bin/bash
# Look for usages of PropertyDeclAccessorBuilder to understand how it's used
rg -n "PropertyDeclAccessorBuilder" --type swift -C3

Repository: NSFatalError/PrincipleMacros

Length of output: 2020


🏁 Script executed:

#!/bin/bash
# Find PropertyDeclBuilder protocol definition
rg -n "protocol PropertyDeclBuilder" --type swift -A10

Repository: NSFatalError/PrincipleMacros

Length of output: 1210


🏁 Script executed:

#!/bin/bash
# Search for implementations or conformances to PropertyDeclAccessorBuilder
rg -n "PropertyDeclAccessorBuilder" --type swift -B3 -A15

Repository: NSFatalError/PrincipleMacros

Length of output: 2450


🏁 Script executed:

#!/bin/bash
# Look at the project's Package.swift or similar to understand SwiftSyntax version
fd -type f -name "Package.swift" -o -name "Package.resolved" | head -5 | xargs cat

Repository: NSFatalError/PrincipleMacros

Length of output: 242


🏁 Script executed:

#!/bin/bash
# Find Package.swift
find . -name "Package.swift" -o -name "Package.resolved" | head -3 | xargs cat 2>/dev/null | head -100

Repository: NSFatalError/PrincipleMacros

Length of output: 1978


🏁 Script executed:

#!/bin/bash
# Search for types that conform to PropertyDeclAccessorBuilder
rg -n "PropertyDeclAccessorBuilder" --type swift -C5

Repository: NSFatalError/PrincipleMacros

Length of output: 2450


🏁 Script executed:

#!/bin/bash
# Search for struct/class implementing PropertyDeclAccessorBuilder
rg -n ": PropertyDeclAccessorBuilder" --type swift -A20

Repository: NSFatalError/PrincipleMacros

Length of output: 54


🌐 Web query:

SwiftSyntax 602.0.0 AccessorDeclSyntax DeclSyntax type conversion

💡 Result:

Short answer: AccessorDeclSyntax is not a DeclSyntax (and cannot be implicitly converted to one). In SwiftSyntax 602 you must produce an AccessorDeclSyntax value when an AccessorMacro expects [AccessorDeclSyntax] — returning a DeclSyntax (or trying to cast an AccessorDeclSyntax to DeclSyntax) will fail.

Why: AccessorDeclSyntax represents accessor nodes (get/set/willSet/didSet) and conforms to SyntaxProtocol / AccessorDeclSyntaxProtocol, but it is not a DeclSyntax node (DeclSyntax represents top‑level/peer declarations). The macro APIs differentiate these types, so the compiler enforces returning the exact accessor type for AccessorMacro. Evidence and discussion in the Swift forums shows this exact error when a macro returned DeclSyntax instead of AccessorDeclSyntax. [1][3]

What to do:

  • Build and return AccessorDeclSyntax values directly (use the provided initializers / stringLiteral or the builder closure forms). Examples and workarounds are discussed in the forums and tutorials. [1][3][5]
  • Do not try to wrap or cast an AccessorDeclSyntax into DeclSyntax — that conversion is invalid for accessor nodes. If you actually need to produce a declaration instead, construct a DeclSyntax (e.g., VariableDeclSyntax / FunctionDeclSyntax) and return that from a Peer/Member macro that expects DeclSyntax. [4][6]

Sources:

  • Swift Forums discussion (macro returned DeclSyntax vs expected AccessorDeclSyntax). [1].
  • Example Accessor macro threads (showing how to construct AccessorDeclSyntax). [3][5].
  • SwiftSyntax 602.0.0 release (context for API versions). [6]

If you want, paste the code that fails and I’ll show the minimal change to return a proper AccessorDeclSyntax.


AccessorDeclSyntax cannot be converted to DeclSyntax—this code will not compile.

In SwiftSyntax 602.0.0, AccessorDeclSyntax and DeclSyntax are distinct, non-convertible types. AccessorDeclSyntax represents accessor nodes (get, set, willSet, didSet) that conform to SyntaxProtocol, while DeclSyntax represents top-level declarations. The mapping at line 19 attempting to convert [AccessorDeclSyntax] to [DeclSyntax] via DeclSyntax.init will result in a compiler error.

The build() method signature declares a return type of [DeclSyntax], but buildAccessors() produces [AccessorDeclSyntax]. Either:

  • Change the protocol's build() return type to [AccessorDeclSyntax] if the intent is to return accessors, or
  • Implement build() to construct actual declarations (e.g., VariableDeclSyntax) containing the accessors in an AccessorBlockSyntax.
🤖 Prompt for AI Agents
In
Sources/PrincipleMacros/Builders/Declarations/Members/PropertyDeclAccessorBuilder.swift
around lines 18–20, the build() method returns [DeclSyntax] but buildAccessors()
yields [AccessorDeclSyntax] which cannot be converted to DeclSyntax; either
change the method signature to return [AccessorDeclSyntax] if callers expect
accessors, or construct a proper declaration that contains the accessors (for
example create an AccessorBlockSyntax from buildAccessors() and embed it in a
VariableDeclSyntax or other appropriate DeclSyntax) and return that; update any
protocol or caller types if you change the return type.

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftSyntaxMacros
public protocol ClassDeclBuilder: TypeDeclBuilder {

var declaration: ClassDeclSyntax { get }
var trimmedSuperclassType: TypeSyntax? { get }
}

extension ClassDeclBuilder {
Expand All @@ -19,3 +20,20 @@ extension ClassDeclBuilder {
declaration
}
}

extension ClassDeclBuilder {

public var trimmedSuperclassType: TypeSyntax? {
nil
}

public var inheritedOverrideModifier: TokenSyntax? {
trimmedSuperclassType != nil
? TokenSyntax(.keyword(.override), presence: .present).withTrailingSpace
: nil
}

public var inheritedFinalModifier: TokenSyntax? {
declaration.finalSpecifier?.trimmed.withTrailingSpace
}
}
22 changes: 22 additions & 0 deletions Sources/PrincipleMacros/Diagnostics/DiagnosticsError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// DiagnosticsError.swift
// PrincipleMacros
//
// Created by Kamil Strzelecki on 21/11/2025.
// Copyright © 2025 Kamil Strzelecki. All rights reserved.
//

import SwiftSyntaxMacros

extension DiagnosticsError {

public init(
node: some SyntaxProtocol,
message: String,
fixIts: [FixIt] = []
) {
let message = MacroExpansionErrorMessage(message)
let diagnostic = Diagnostic(node: node, message: message, fixIts: fixIts)
self.init(diagnostics: [diagnostic])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ extension MacroExpansionContext {

public func diagnose(
node: some SyntaxProtocol,
errorMessage: String
errorMessage: String,
fixIts: [FixIt] = []
) {
let message = MacroExpansionErrorMessage(errorMessage)
let diagnostic = Diagnostic(node: node, message: message)
let diagnostic = Diagnostic(node: node, message: message, fixIts: fixIts)
diagnose(diagnostic)
}

public func diagnose(
node: some SyntaxProtocol,
warningMessage: String
warningMessage: String,
fixIts: [FixIt] = []
) {
let message = MacroExpansionWarningMessage(warningMessage)
let diagnostic = Diagnostic(node: node, message: message)
let diagnostic = Diagnostic(node: node, message: message, fixIts: fixIts)
diagnose(diagnostic)
}
}
68 changes: 62 additions & 6 deletions Sources/PrincipleMacros/Parameters/ParameterExtractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ extension ParameterExtractor {
}
}

extension ParameterExtractor {

public func rawBool(
withLabel label: TokenSyntax?
) throws -> Bool? {
guard let expression = expression(withLabel: label) else {
return nil
}

guard let bool = expression.as(BooleanLiteralExprSyntax.self) else {
throw ParameterExtractionError.unexpectedSyntaxType
}

return bool.literal.tokenKind == .keyword(.true)
}

public func requiredRawBool(
withLabel label: TokenSyntax?
) throws -> Bool {
guard let bool = try rawBool(withLabel: label) else {
throw ParameterExtractionError.missingRequirement
}
return bool
}
}

extension ParameterExtractor {

public func rawString(
Expand Down Expand Up @@ -160,18 +186,20 @@ extension ParameterExtractor {
return nil
}

if NilLiteralExprSyntax(expression) != nil {
if expression.is(NilLiteralExprSyntax.self) {
let isolation = DeclModifierSyntax(name: .keyword(.nonisolated))
return .nonisolated(trimmedModifer: isolation)
}

if let memberAccessExpression = MemberAccessExprSyntax(expression),
let explicitType = memberAccessExpression.base?.inferredType,
memberAccessExpression.referencesBaseType {
return .isolated(standardizedType: explicitType.standardized)
guard let memberAccessExpression = MemberAccessExprSyntax(expression),
let globalActorType = memberAccessExpression.baseTypeReference
else {
throw ParameterExtractionError.unexpectedSyntaxType
}

throw ParameterExtractionError.unexpectedSyntaxType
return .isolated(
standardizedType: globalActorType.standardized
)
}

public func requiredGlobalActorIsolation(
Expand All @@ -183,3 +211,31 @@ extension ParameterExtractor {
return isolation
}
}

extension ParameterExtractor {

public func type(
withLabel label: TokenSyntax?
) throws -> TypeSyntax? {
guard let expression = expression(withLabel: label) else {
return nil
}

guard let memberAccessExpression = MemberAccessExprSyntax(expression),
let type = memberAccessExpression.baseTypeReference
else {
throw ParameterExtractionError.unexpectedSyntaxType
}

return type
}

public func requiredType(
withLabel label: TokenSyntax?
) throws -> TypeSyntax {
guard let type = try type(withLabel: label) else {
throw ParameterExtractionError.missingRequirement
}
return type
}
Comment on lines +217 to +240
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add documentation for public API methods.

These new public methods lack doc comments explaining their purpose, parameters, return values, and error conditions. Since they're part of the public API, documentation would improve discoverability and usage.

Consider adding documentation like:

/// Extracts a type from a labeled expression of the form `Type.self`.
///
/// - Parameter label: The label of the parameter to extract, or `nil` for unlabeled parameters.
/// - Returns: The extracted type syntax, or `nil` if no expression with the given label exists.
/// - Throws: `ParameterExtractionError.unexpectedSyntaxType` if the expression is not a member access with a base type reference.
public func type(
    withLabel label: TokenSyntax?
) throws -> TypeSyntax? {
🤖 Prompt for AI Agents
In Sources/PrincipleMacros/Parameters/ParameterExtractor.swift around lines 191
to 214, the public methods `type(withLabel:)` and `requiredType(withLabel:)`
lack documentation; add Swift doc comments for both methods describing their
purpose, the `label` parameter (nil meaning unlabeled), the return value
(optional TypeSyntax for `type`, non-optional for `requiredType`), and the
thrown errors (`ParameterExtractionError.unexpectedSyntaxType` for `type` when
the expression isn't a member access with a base type reference, and
`ParameterExtractionError.missingRequirement` for `requiredType` when no type is
found); keep comments concise and follow the Swift /// style used across the
project so documentation is picked up by Xcode and swift-doc tools.

}
46 changes: 39 additions & 7 deletions Sources/PrincipleMacros/Parsers/Common/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,44 @@ public protocol Parser {
associatedtype ResultsCollection: ParserResultsCollection

static func parse(
declaration: some DeclSyntaxProtocol,
in context: some MacroExpansionContext
) -> ResultsCollection
declaration: some DeclSyntaxProtocol
) throws -> ResultsCollection
}

static func parse(
memberBlock: MemberBlockSyntax,
in context: some MacroExpansionContext
) -> ResultsCollection
extension Parser {

public static func parse(
ifConfig: IfConfigDeclSyntax
) throws -> ResultsCollection {
try ResultsCollection(
ifConfig.clauses.flatMap { clause in
switch clause.elements {
case let .decls(members):
try parse(members: members)
default:
ResultsCollection()
}
}
)
}

public static func parse(
members: MemberBlockItemListSyntax
) throws -> ResultsCollection {
try ResultsCollection(
members.flatMap { member in
if let ifConfig = member.decl.as(IfConfigDeclSyntax.self) {
try parse(ifConfig: ifConfig)
} else {
try parse(declaration: member.decl)
}
}
)
}

public static func parse(
memberBlock: MemberBlockSyntax
) throws -> ResultsCollection {
try parse(members: memberBlock.members)
}
Comment on lines 15 to +55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Parser helpers for declarations, members, and if-configs are well factored — verify conformers’ signatures

The new throws-based Parser.parse(declaration:) requirement and the added parse(ifConfig:), parse(members:), and parse(memberBlock:) helpers give a clear, reusable traversal story for members and nested #if blocks. The flat-mapping of per-clause/per-member ResultsCollections into a single ResultsCollection matches the existing collection design.

One thing to double-check is that every Parser conformer’s parse(declaration:) implementation and all call sites have been updated to the new throws signature where appropriate.


🏁 Script executed:

#!/bin/bash
# Find non-throwing parse(declaration:) implementations that may need updating.
rg -nP 'static\s+func\s+parse\(\s*declaration:\s*some\s+DeclSyntaxProtocol\s*\)\s*->' Sources

Length of output: 0



🏁 Script executed:

#!/bin/bash
# Find the Parser protocol definition and all conformers
echo "=== Finding Parser protocol definition ==="
rg -nA5 'protocol\s+Parser' Sources

echo ""
echo "=== Finding types that conform to Parser ==="
rg -nP '\b(struct|class|enum)\s+\w+.*Parser\b' Sources

echo ""
echo "=== Finding all parse\(declaration: signatures (simplified) ==="
rg -nP 'parse\s*\(\s*declaration:' Sources

Length of output: 2102


🏁 Script executed:

#!/bin/bash
# Find the Parser protocol definition and all conformers
echo "=== Finding Parser protocol definition ==="
rg -nA5 'protocol\s+Parser' Sources

echo ""
echo "=== Finding types that conform to Parser ==="
rg -nP '\b(struct|class|enum)\s+\w+.*Parser\b' Sources

echo ""
echo "=== Finding all parse\(declaration: signatures (simplified) ==="
rg -nP 'parse\s*\(\s*declaration:' Sources

Length of output: 2102


🏁 Script executed:

#!/bin/bash
# Check EnumCasesParser.parse(declaration:) signature
echo "=== EnumCasesParser.parse(declaration:) ==="
rg -nA3 'static\s+func\s+parse' Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift

echo ""
echo "=== PropertiesParser.parse(declaration:) ==="
rg -nA3 'static\s+func\s+parse' Sources/PrincipleMacros/Parsers/Properties/PropertiesParser.swift

Length of output: 463


EnumCasesParser.parse(declaration:) must be updated to match the new throws protocol requirement

The Parser protocol now requires parse(declaration:) to throw, but EnumCasesParser's implementation at Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift:13 is still missing the throws keyword. PropertiesParser was correctly updated, but EnumCasesParser was not. Update the signature to:

public static func parse(declaration: some DeclSyntaxProtocol) throws -> EnumCasesList
🤖 Prompt for AI Agents
Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift around line 13:
the parse(declaration:) implementation is missing the throws keyword and should
match the protocol; change the function signature to be public static func
parse(declaration: some DeclSyntaxProtocol) throws -> EnumCasesList and update
its body to propagate errors (use try where calling other throwing parsers) so
the implementation compiles against the protocol.

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ where Element: ParserResult {
associatedtype Element

var all: [Element] { get }

init(_ all: [Element])
}

extension ParserResultsCollection {
Expand All @@ -28,3 +30,16 @@ extension ParserResultsCollection {
all[position]
}
}

extension ParserResultsCollection {

public init() {
self.init([])
}

public func filter(
_ isIncluded: (Element) throws -> Bool
) rethrows -> Self {
try Self(filter(isIncluded))
}
}
Loading
Loading