Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Dec 5, 2025

The value should be wrapped (or overloads split) instead of force-cast.

The value should be wrapped (or overloads split) instead of force-cast.

public func evaluate(_ bindings: PredicateBindings) throws -> Output {
// When the transform produces a non-optional Result, wrap it.
public func evaluate(_ bindings: PredicateBindings) throws -> Output where RHS.Output == Result {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate more on the intent of this change? The existing public func evaluate is a witness to a protocol requirement from PredicateExpression. PredicateExpression requires that all expressions must be able to be evaluated without additional constraints, so the two new public APIs that you've added no longer satisfy this protocol requirement and I don't expect that it would build successfully. IIRC the split initializers (not protocol requirements) were necessary to "simulate" the compiler's implicit optional promotion when returning a non-optional value from a function with an optional return type which does not apply to generic signature requirements in the same way. The existing force cast in the evaluate function performs that optional promotion at runtime like the compiler would have inserted if this were a "real" closure.

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