Skip to content

Replace most generated code in SyntaxCollections.swift by default protocol implementations #1787

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 15, 2023

This has two advantages.

  1. It reduces the amout of code in swift-syntax
  2. It actually makes all the functions defined in every SyntaxCollection accessible for existentials or generics over SyntaxCollection.

@ahoppen ahoppen requested a review from bnbarham June 15, 2023 00:24
@@ -173,7 +173,7 @@ extension ExprListSyntax: ExpressibleByArrayLiteral {
public init(_ elements: [ExprSyntaxProtocol]) {
self = ExprListSyntax(elements.map {
ExprSyntax(fromProtocol: $0)
})
} as [ExprSyntax])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed now?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it’s something to do with the initializer being moved to an extension and thus it doesn’t have higher precedence than this initializer that that takes [ExprSyntaxProtocol] anymore. But I haven’t reduced it to a minimal reproducer.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

This much code deletion brings happy tears

@ahoppen
Copy link
Member Author

ahoppen commented Jun 15, 2023

@swift-ci Please test

@ahoppen ahoppen force-pushed the ahoppen/collection-conformance branch from 5d10772 to 3276f80 Compare June 15, 2023 05:04
@ahoppen
Copy link
Member Author

ahoppen commented Jun 15, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 15, 2023

@swift-ci Please test Windows

Copy link
Contributor

@kimdv kimdv left a comment

Choose a reason for hiding this comment

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

😍

…tocol implementations

This has two advantages.

1. It reduces the amout of code in swift-syntax
2. It actually makes all the functions defined in every `SyntaxCollection` accessible for existentials or generics over `SyntaxCollection`.
@ahoppen ahoppen force-pushed the ahoppen/collection-conformance branch from 3276f80 to f8d304c Compare June 15, 2023 15:10
@ahoppen
Copy link
Member Author

ahoppen commented Jun 15, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 15, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 73a28b1 into swiftlang:main Jun 16, 2023
@ahoppen ahoppen deleted the ahoppen/collection-conformance branch June 16, 2023 13:01
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.

4 participants