Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
.plugin(name: "MetaProtocolCodable", targets: ["MetaProtocolCodable"]),
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.1.0"..<"602.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.1.0"..<"603.0.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/HelperCoders/ValueCoders/Number.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
protocol NumberCodingStrategy: ValueCodingStrategy where Value == Self {}

public extension ValueCodingStrategy
where Value: Decodable & ExpressibleByIntegerLiteral & LosslessStringConvertible
where Value: Decodable & ExpressibleByIntegerLiteral & LosslessStringConvertible & Sendable
{
/// Decodes numeric data from the given `decoder`.
///
Expand Down
21 changes: 14 additions & 7 deletions Sources/PluginCore/Variables/Type/EnumVariable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ package struct EnumVariable: TypeVariable, DeclaredVariable {
let caseEncodeExpr: CaseCode = { name, variables in
let args = Self.encodingArgs(representing: variables)
let callee: ExprSyntax = ".\(name)"
let fExpr =
if !args.isEmpty {
FunctionCallExprSyntax(callee: callee) { args }
} else {
FunctionCallExprSyntax(calledExpression: callee) {}
}
return ExprSyntax(fExpr)
if args.isEmpty {
/// No associated values: return just the case name without parentheses
return callee
} else {
let fExpr = FunctionCallExprSyntax(
calledExpression: callee,
leftParen: .leftParenToken(),
arguments: args,
rightParen: .rightParenToken(),
trailingClosure: nil
)
return ExprSyntax(fExpr)
}
}
self.init(
from: decl, in: context,
Expand Down Expand Up @@ -878,3 +884,4 @@ fileprivate extension EnumVariable {
/// This encoder is passed to each case for encoding.
static var contentEncoder: TokenSyntax { "contentEncoder" }
}

10 changes: 10 additions & 0 deletions Tests/MetaCodableTests/ConformCodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ struct ConformEncodableTests {
.init(message: "Remove @ConformEncodable attribute")
]
),
.init(
id: Codable.misuseID,
message:
"@Codable can't be used in combination with @ConformEncodable",
line: 2, column: 1,
fixIts: [
.init(message: "Remove @Codable attribute")
]
),
Comment on lines +41 to +49
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

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

This diagnostic entry appears to be a duplicate of the diagnostic at lines 59-67. Both have the same id (Codable.misuseID), message, line, column, and fixIt. Consider removing this duplicate entry to avoid test redundancy.

Copilot uses AI. Check for mistakes.
.init(
id: ConformEncodable.misuseID,
message:
Expand Down Expand Up @@ -491,3 +500,4 @@ struct ConformDecodableTests {
}
}
}