Skip to content

Add an initializer to construct Syntax nodes from syntax protocol types #223

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 3, 2020

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 3, 2020

Resolving https://forums.swift.org/t/swiftsyntax-as-conversions/37166, we are missing an initialiser to create Syntax nodes from SyntaxProtocol (and ExprSyntaxProtocol etc.) types. This adds the necessary initialiser.

Note that I needed to add an argument label fromProtocol to the initialiser to avoid ambiguity with the following existing initialiser. I think it also makes it clear that we are dealing with existentials here, similar to how we have asProtocol etc.

public init<S: SyntaxProtocol>(_ syntax: S) {
  self = syntax._syntaxNode
}

@ahoppen ahoppen requested a review from akyrtzi June 3, 2020 08:40
@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2020

@swift-ci Please test

@akyrtzi akyrtzi merged commit 09591a7 into swiftlang:master Jun 3, 2020
@ahoppen ahoppen deleted the constructor-from-syntax-protocol branch June 4, 2020 15:35
adevress pushed a commit to adevress/swift-syntax that referenced this pull request Jan 14, 2024
Convert some rules to be opt-in because they are noisy for non-strict…
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