Skip to content
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

Trials.reject should be compatible with any type. #68

Open
sageserpent-open opened this issue Dec 1, 2023 · 1 comment
Open

Trials.reject should be compatible with any type. #68

sageserpent-open opened this issue Dec 1, 2023 · 1 comment

Comments

@sageserpent-open
Copy link
Owner

Trials.reject currently is typed to yield Unit in Scala and void in Java. This means that it can't be used in a value expression, so it tends to end up either in a guard block or is hoisted right up to a catch clause of a try construct that encloses the entire parameterised test.

It would be nice to make it more like Scala's ??? operator, so it can be used anywhere, safe in the knowledge that it always throw an exception and is thus nominally compatible with any expected type.

Not sure what the equivalent in Java would be - maybe define it as a generic method and hope that type inference will be able to unify at its call sites?

@sageserpent-open
Copy link
Owner Author

JUnit5's Assertions.fail uses the generic approach and that seems to work nicely, so that's what we'll do for the Java flavour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant