Skip to content
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

Conform Array to various ExpressibleAs protocols in BuildableCollectionNodes #461

Merged

Conversation

fwcd
Copy link
Member

@fwcd fwcd commented Jun 9, 2022

In a separate PR (from #460) for easier reviewability. This adds a bunch of Array conformances that let us initialize syntax collections more conveniently, for example:

ExtensionDecl(
  modifiers: [...],
  ...
)

instead of

ExtensionDecl(
  modifiers: ModifierList([...]),
  ...
)

(This applies whenever the parameter has an existential type a la ExpressibleAsModifierList, in which case the compiler cannot infer that we would like to use the ExpressibleByArrayLiteral conformance from ModifierList)

cc @ahoppen

@fwcd fwcd requested a review from ahoppen as a code owner June 9, 2022 02:52
@fwcd fwcd force-pushed the buildable-collections-array-conformances branch from 5909717 to 4726f15 Compare June 9, 2022 02:55
@kimdv
Copy link
Contributor

kimdv commented Jun 9, 2022

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Nice. This looks great. Could you add a couple test cases?

Always use existential expressible types in Array conformance bounds.
This lets us use heterogenous arrays and matches the initializers of the
actual structures.

Add some tests for the new Array conformances.
@fwcd fwcd force-pushed the buildable-collections-array-conformances branch from 4726f15 to 93b7852 Compare June 9, 2022 16:12
@fwcd
Copy link
Member Author

fwcd commented Jun 9, 2022

Sure, I've added a few tests. Additionally, I have updated the conformance clause to always test for equality against the element type, i.e. use existentials. This is slightly more flexible and more consistent with the existing initializers e.g. in ModifierList, which also take a list of existentials ([ExpressibleAsDeclModifier]).

@kimdv
Copy link
Contributor

kimdv commented Jun 9, 2022

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thanks. Looks great!

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.

3 participants