Skip to content

Commit

Permalink
Updated documentation for loosened return type matching of provider m…
Browse files Browse the repository at this point in the history
…ethods.
  • Loading branch information
jlink committed Nov 28, 2024
1 parent 48cda86 commit 27b9c5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# 1.9.2

- Bug with provider method type matching in interface default methods.
See https://github.com/jqwik-team/jqwik/issues/599.

# 1.9.x

- Summon preconfigured arbitrary. See https://github.com/jqwik-team/jqwik/issues/527
Expand Down
15 changes: 11 additions & 4 deletions documentation/src/docs/include/customized-parameter-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ If the return type cannot be matched, jqwik will throw a `CannotFindArbitraryExc

**Caveat:**

Up to version `1.7.4`, it was possible that the provider method's return type
was broader than the property method's parameter type.
Since version `1.8.0` this is no longer the case.
That's why the following code _will now fail at runtime_ with a `CannotFindArbitraryException`:
Between versions `1.8.0` and `1.9.1`, matching the provider method's return type to the parameter type was very strict.
That's why the following code _would fail at runtime_ with a `CannotFindArbitraryException`:

```java
@Property
Expand All @@ -58,6 +56,15 @@ Arbitrary<?> favouritePrimes() {
}
```

Starting with version `1.9.2` return type matching is very loose again.
The only enforced constraint is that the return type must be a subtype of `Arbitrary`.
Therefore the above code will work again.

_The downside:_ If the arbitrary provided by the method will create an object of the wrong type,
there will be an `IllegalArgumentException` thrown when jqwik tries to execute the property method.
This is a trade-off between strict type checking and convenience.


#### How to write a provider method

Arbitrary provision often starts with a
Expand Down

0 comments on commit 27b9c5b

Please sign in to comment.