Skip to content

Conversation

@qizh
Copy link

@qizh qizh commented Nov 27, 2025

This pull request updates dependencies, improves enum case encoding logic, enhances protocol constraints for numeric value coders, and adds a new test for attribute misuse. The changes focus on compatibility, correctness, and improved diagnostics.

Dependency update:

  • Increased the upper bound for the swift-syntax package dependency to allow versions up to 603.0.0, ensuring compatibility with newer releases.

Enum encoding logic improvements:

  • Refactored the enum case encoding in EnumVariable so that cases without associated values are encoded as just the case name, without parentheses, improving the correctness of generated code.

Protocol constraint enhancement:

  • Added the Sendable constraint to the generic requirements for numeric value coding strategies, improving safety for concurrent use.

Testing and diagnostics:

  • Added a new test case to ConformEncodableTests to check for misuse when @Codable is used in combination with @ConformEncodable, providing better diagnostics for attribute conflicts.

qizh added 2 commits November 27, 2025 21:34
- [x] Bumped `swift-syntax` dependency to allow up to `603.0.0`.
- [x] Added `SendableMetatype` constraint to `NumberCodingStrategy` extension.
- [x] Refactored `caseEncodeExpr` in `EnumVariable` for consistent `FunctionCallExprSyntax` usage.
- [x] Corrected indentation for the `caseEncodeExpr` closure to maintain consistent formatting.
@qizh qizh marked this pull request as ready for review November 27, 2025 14:42
Copilot AI review requested due to automatic review settings November 27, 2025 14:42
Copilot finished reviewing on behalf of qizh November 27, 2025 14:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the swift-syntax dependency to support versions up to 603.0.0 and addresses breaking API changes introduced in newer versions of the library.

  • Updated swift-syntax version range from "509.1.0"..<"602.0.0" to "509.1.0"..<"603.0.0"
  • Refactored FunctionCallExprSyntax initialization to use calledExpression: parameter instead of deprecated callee:
  • Added SendableMetatype constraint to ValueCodingStrategy extension for number types

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Package.swift Bumped swift-syntax dependency upper bound to 603.0.0
Sources/PluginCore/Variables/Type/EnumVariable.swift Updated FunctionCallExprSyntax API usage from callee: to calledExpression: for consistency
Sources/HelperCoders/ValueCoders/Number.swift Added SendableMetatype constraint to ValueCodingStrategy extension

@qizh qizh marked this pull request as draft November 27, 2025 14:47
qizh added 3 commits November 27, 2025 22:30
Replaces the `SendableMetatype` constraint with `Sendable` in the `ValueCodingStrategy` extension to align with updated protocol requirements or type definitions.
- [x] Refactors `caseEncodeExpr` to return only the case name for enum cases without associated values, avoiding unnecessary parentheses.
  This improves code generation for enums with simple cases.
- [x] Update `ConformEncodableTests.misuseWithCodable` to expect four diagnostics.
- [x] Ensure diagnostic IDs, messages, fix-its, and line/column positions match emitted results:
  - [x] Two diagnostics for `@ConformEncodable` at line 1, column 1.
  - [x] Two diagnostics for `@Codable` at line 2, column 1.
  - [x] Mirrors the pattern already used in `misuseWithDecodable`.
@qizh qizh marked this pull request as ready for review November 27, 2025 16:03
@qizh qizh requested a review from Copilot November 27, 2025 16:05
Copilot finished reviewing on behalf of qizh November 27, 2025 16:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +41 to +49
.init(
id: Codable.misuseID,
message:
"@Codable can't be used in combination with @ConformEncodable",
line: 2, column: 1,
fixIts: [
.init(message: "Remove @Codable attribute")
]
),
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.
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