-
Notifications
You must be signed in to change notification settings - Fork 49
Add primary associated type to RegexComponent #454
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
Add primary associated type to RegexComponent #454
Conversation
@swift-ci Please test |
* Add a primary associated type to RegexComponent * Switch algorithms methods to using opaque params * Use primary assoc type in RegexBuilder algorithms
@available(SwiftStdlib 5.7, *) | ||
public func contains<R: RegexComponent>( | ||
@RegexComponentBuilder _ content: () -> R | ||
public func contains( | ||
@RegexComponentBuilder _ content: () -> some RegexComponent | ||
) -> Bool { | ||
contains(content()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I believe these will fail to integrate with the current Swift compiler due to rdar://92459215, see the comment at the top of the file (I don't know if some RegexComponent<Output>
works tho)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh huh, I see swiftlang/swift#42532 passed, maybe that's just an issue on main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #458 to verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, seems to be fixed now (other test failure unrelated)
Edit: Looks like it was fixed by swiftlang/swift#58991
* Add a primary associated type to RegexComponent * Switch algorithms methods to using opaque params * Use primary assoc type in RegexBuilder algorithms
This PR makes the
RegexOutput
associated type primary forRegexComponent
, and adopts the new lightweight generics syntax across the algorithms methods. With this change, methods that don't rely on the specific output type no longer have an explicit generic parameter:And methods that do are generic over that type instead of over the regex component type:
(Technically these are all just sugared versions of the old ones, but they do look nicer.)