Skip to content

Add default conformance to syntax collection #334

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

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented Nov 10, 2021

swiftlang/swift#40120

Added default conformance to syntax collection as discussed in #331

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.

LGTM. Will probably need some adjustment based on which changes will be made to swiftlang/swift#40120.

@kimdv kimdv force-pushed the kimdv/add-default-conformance-to-syntax-collection branch 7 times, most recently from 05810f0 to fe3d42b Compare November 15, 2021 17:57

% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES.items():
% if 'ConditionElement' in conformances:
extension ExpressibleBy${protocol} {
Copy link
Member

Choose a reason for hiding this comment

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

Not part of this PR, but couldn’t we also generate these extension implementations now that syntax collection conformances live somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be nice!
But the thing is, that the init method different for each type.

We can enrich the protocols.pyfile with the needed information.

Copy link
Member

Choose a reason for hiding this comment

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

Why is that? Am I missing something obvious? Shouldn’t the following work?

extension ExpressibleBy${protocol} {
   public func create${expressible_as_protocol}() -> ${expressible_as_protocol} {
     ${expressible_as_protocol}(${retrieve only non-optional child name here}: self)
   }
 }

Copy link
Contributor Author

@kimdv kimdv Nov 16, 2021

Choose a reason for hiding this comment

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

Sorry bad explanation 😅

extension ExpressibleByDeclBuildable {
  public func createCodeBlockItem() -> CodeBlockItem {
    CodeBlockItem(item: self)
  }
}

extension ExpressibleByDeclBuildable {
  public func createMemberDeclListItem() -> MemberDeclListItem {
    MemberDeclListItem(decl: self)
  }
}

Yes. The ${retrieve only non-optional child name here} do we need to find somehow.
Not sure how to do, but I will look into it, and then we can take it from there.

It is possible, somehow 😬

@kimdv kimdv force-pushed the kimdv/add-default-conformance-to-syntax-collection branch from fe3d42b to 72e2627 Compare November 16, 2021 17:36
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.

Looking good. Could you rebase because I just reverted my change of ExpressibleAs -> ExpressibleBy because I had a brain fart yesterday. The protocols actually describe that these types are expressible as other types and not by other types. Also make sure to rename all of your bys by ass.

@kimdv kimdv force-pushed the kimdv/add-default-conformance-to-syntax-collection branch from 72e2627 to a52dca1 Compare November 16, 2021 21:57
@kimdv
Copy link
Contributor Author

kimdv commented Nov 16, 2021

I saw that!

I have rebased 🚀

@kimdv
Copy link
Contributor Author

kimdv commented Nov 17, 2021

swiftlang/swift#40120

@swift-ci Please test

1 similar comment
@ahoppen
Copy link
Member

ahoppen commented Nov 17, 2021

swiftlang/swift#40120

@swift-ci Please test

@kimdv kimdv merged commit 22c9714 into swiftlang:main Nov 17, 2021
@kimdv kimdv deleted the kimdv/add-default-conformance-to-syntax-collection branch November 17, 2021 11:35
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.

2 participants