ListArbitrary<T> providers are not selected to resolve List<T> parameters
lmartelli opened this issue · comments
Testing Problem
A @Provide
method in a domain that returns a ListArbitrary<Thing>
is not used to generate values for a @ForAll List<Thing>
. See main...lmartelli:jqwik:ListArbitrary-provider
Suggested Solution
In net.jqwik.engine.properties.DomainContextBaseProviders.MethodBasedArbitraryProvider#arbitraryType()
the actual generic type parameter of ListArbitrary is lost when navigating to the implemented interface Arbitrary.
I am not sure if the mapping can be done in the general case, but it seems safe to say that in the case where there is only one generic type parameter in the class and in the interface, it can be propagated.
I will try to do that.
If you find an easy solution, go ahead.
My recommendation, though: Don't dive too deep into type matching code if there is an easy workaround - just use Arbitrary<List<Thing>>
here. There are too many edge cases concerning co- and contravariance that one can easily have one's soul sucked out trying to cover everything. I already lost too many hours of my life in that area :-/
@lmartelli I assume you haven't found a viable solution. Feel free to re-open if I'm wrong.