-
-
Notifications
You must be signed in to change notification settings - Fork 42
Update swift-syntax version and improve type constraints to resolve errors & warnings
#150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
db33503
a9b3f01
551c9a1
af382df
44558a5
6ca0d90
67ab745
37c080c
ea720d5
0b3f7dc
6da09a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ Package.resolved | |
| *.o | ||
| *.d | ||
| *.swiftdeps* | ||
| *.dia | ||
|
|
||
| # CocoaPods | ||
| # | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ let package = Package( | |
| .product(name: "SwiftDiagnostics", package: "swift-syntax"), | ||
| .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), | ||
| .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), | ||
| .product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for this change? |
||
| .product(name: "OrderedCollections", package: "swift-collections"), | ||
| ] | ||
| ), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ let package = Package( | |
| .product(name: "SwiftDiagnostics", package: "swift-syntax"), | ||
| .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), | ||
| .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), | ||
| .product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for this change? |
||
| .product(name: "OrderedCollections", package: "swift-collections"), | ||
| ] | ||
| ), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,9 @@ extension TaggedEnumSwitcherVariable { | |
| /// - location: The decoding location. | ||
| /// - coder: The decoder for cases. | ||
| /// - context: The context in which to perform the macro expansion. | ||
| /// - default: Whether default case is needed. | ||
| /// - default: Whether default case is needed. Note that for Bool type, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would love to see this warning fixed as well, but your changes seem to be breaking following code expansion for example: @Codable
@CodedAt("type")
enum Command {
@CodedAs("load", 12, true)
case load(key: String)
@CodedAs("store", 30)
case store(key: String, value: Int)
}Can you make the changes to fix above scenario? |
||
| /// the default case is automatically skipped since both true and false | ||
| /// cases are explicitly handled, avoiding unreachable default warnings. | ||
| /// - forceDecodingReturn: Whether to force explicit `return` statements in each | ||
| /// switch case. When `true`, adds a `return` statement after the case assignment | ||
| /// for early exit. Defaults to `false` for backward compatibility. | ||
|
|
@@ -60,7 +62,7 @@ extension TaggedEnumSwitcherVariable { | |
| } | ||
| } | ||
|
|
||
| if `default` { | ||
| if `default` && header.type != .bool { | ||
| SwitchCaseSyntax(label: .default(.init())) { | ||
| "break" | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,15 +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, leftParen: nil, rightParen: nil | ||
| ) {} | ||
| } | ||
| return ExprSyntax(fExpr) | ||
| if args.isEmpty { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for this change? May be you can add some test cases that demonstrates what this fixes? |
||
| /// 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, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -464,3 +464,4 @@ struct ConformDecodableTests { | |
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this, changelog is automatically generated. You can remove this.