Skip to content

[5.7] Cherry pick a RegexBuilder and StringProcessing change #534

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

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Jul 1, 2022

Cherry pick of:

This is the last of the RegexBuilder + StringProcessing changes currently left on main.

rxwei and others added 3 commits July 1, 2022 11:29
Currently, unary regex component builder simply forwards the component's base type. However, this is inconsistent with non-unary builder results. The current behavior may lead to surprising results when the user marks a property with `@RegexComponentBuilder`.

This patch makes `RegexComponentBuilder.buildPartialBlock<R>(first: R)` return a `Regex<R.RegexOutput>` rather than `R` itself.

---

Before:

```swift
// error: cannot convert value of type 'OneOrMore<Substring>' to specified type 'Regex<Substring>'
@RegexComponentBuilder
var r: Regex<Substring> {
  OneOrMore("a")
  // Adding other components below will make the error go away.
}

struct MyCustomRegex: RegexComponent {
  // error: cannot convert value of type 'OneOrMore<Substring>' to specified type 'Regex<Substring>'
  var regex: Regex<Substring> {
    OneOrMore("a")
  }
}
```

After: No errors.
rdar://92459215 has been fixed.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit e37cf13 into swiftlang:swift/release/5.7 Jul 1, 2022
@hamishknight hamishknight deleted the more-5.7-cherry-picks branch July 1, 2022 15:15
@hamishknight hamishknight added the r5.7 5.7 Release Cherry Picks label Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r5.7 5.7 Release Cherry Picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants