Skip to content

[5.9] Add missing trait conformances #1788

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

Merged
merged 1 commit into from
Jun 16, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public let ATTRIBUTE_NODES: [Node] = [
nameForDiagnostics: "version",
description: "A single platform/version pair in an attribute, e.g. `iOS 10.1`.",
kind: "Syntax",
traits: ["WithTrailingComma"],
children: [
Child(
name: "AvailabilityVersionRestriction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public let AVAILABILITY_NODES: [Node] = [
nameForDiagnostics: "availability argument",
description: "A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: \"This has been deprecated\"`.",
kind: "Syntax",
traits: ["WithTrailingComma"],
children: [
Child(
name: "Entry",
Expand Down
2 changes: 2 additions & 0 deletions CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@ public let DECL_NODES: [Node] = [
name: "PrecedenceGroupNameElement",
nameForDiagnostics: nil,
kind: "Syntax",
traits: ["WithTrailingComma"],
children: [
Child(
name: "Name",
Expand Down Expand Up @@ -2095,6 +2096,7 @@ public let DECL_NODES: [Node] = [
traits: [
"IdentifiedDecl",
"WithAttributes",
"WithModifiers",
],
children: [
Child(
Expand Down
8 changes: 7 additions & 1 deletion Sources/SwiftSyntax/generated/SyntaxTraits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ extension AssociatedtypeDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax,

extension AttributedTypeSyntax: WithAttributesSyntax {}

extension AvailabilityArgumentSyntax: WithTrailingCommaSyntax {}

extension AvailabilityVersionRestrictionListEntrySyntax: WithTrailingCommaSyntax {}

extension CaseItemSyntax: WithTrailingCommaSyntax {}

extension CatchClauseSyntax: WithCodeBlockSyntax {}
Expand Down Expand Up @@ -603,6 +607,8 @@ extension PoundSourceLocationSyntax: ParenthesizedSyntax {}

extension PrecedenceGroupDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension PrecedenceGroupNameElementSyntax: WithTrailingCommaSyntax {}

extension PrimaryAssociatedTypeSyntax: WithTrailingCommaSyntax {}

extension ProtocolDeclSyntax: DeclGroupSyntax, IdentifiedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}
Expand Down Expand Up @@ -635,7 +641,7 @@ extension TupleTypeSyntax: ParenthesizedSyntax {}

extension TypeEffectSpecifiersSyntax: EffectSpecifiersSyntax {}

extension TypealiasDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax {}
extension TypealiasDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension VariableDeclSyntax: WithAttributesSyntax, WithModifiersSyntax {}

Expand Down
15 changes: 12 additions & 3 deletions Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ public struct AvailabilitySpecListBuilder {
/// If declared, this will be called on the partial result from the outermost
/// block statement to produce the final returned result.
public static func buildFinalResult(_ component: Component) -> FinalResult {
return .init(component)
let lastIndex = component.count - 1
return .init(component.enumerated().map { index, source in
return index < lastIndex ? source.ensuringTrailingComma() : source
})
}
}

Expand Down Expand Up @@ -499,7 +502,10 @@ public struct AvailabilityVersionRestrictionListBuilder {
/// If declared, this will be called on the partial result from the outermost
/// block statement to produce the final returned result.
public static func buildFinalResult(_ component: Component) -> FinalResult {
return .init(component)
let lastIndex = component.count - 1
return .init(component.enumerated().map { index, source in
return index < lastIndex ? source.ensuringTrailingComma() : source
})
}
}

Expand Down Expand Up @@ -3128,7 +3134,10 @@ public struct PrecedenceGroupNameListBuilder {
/// If declared, this will be called on the partial result from the outermost
/// block statement to produce the final returned result.
public static func buildFinalResult(_ component: Component) -> FinalResult {
return .init(component)
let lastIndex = component.count - 1
return .init(component.enumerated().map { index, source in
return index < lastIndex ? source.ensuringTrailingComma() : source
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ final class MacroSystemTests: XCTestCase {
expandedSource: #"""
struct S {
@attr static var value1 = 1
@attr typealias A = B
@attr static typealias A = B
}
"""#,
macros: ["decls": DeclsFromStringsMacro.self],
Expand Down