-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Type arguments are missing in some situations #492
Comments
Quite a complicated setup you have there ;-) Still trying to wrap my head around it. What is the actual value of And yes, a reproducible example would help me figure out the problem more easily. |
Agreed !
I've created a simple test project here : https://github.com/lmartelli/jqwik-issue-492
package net.jqwik.issue_492;
import net.jqwik.api.*;
import net.jqwik.api.domains.Domain;
import net.jqwik.api.domains.DomainContext;
import net.jqwik.api.domains.DomainContextBase;
import net.jqwik.api.providers.ArbitraryProvider;
import net.jqwik.api.providers.TypeUsage;
import java.util.Set;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
@Domain(BugTest.ConfigurationDomain.class)
@PropertyDefaults(tries = 10)
public class BugTest {
public abstract class Inner1<PARAMS> {
@Property
void genericProperty(@ForAll PARAMS params) {
System.out.println("params = " + params);
assertThat(params).isNotNull();
}
}
@Group
public class Inner2<T> extends Inner1<GenericType<T>> {
}
public record GenericType<T>(T value) {
}
@Group
class Inner3 extends Inner2<String> {
}
@Domain(DomainContext.Global.class)
static class ConfigurationDomain extends DomainContextBase {
public class GenericTypeArbitraryProvider implements ArbitraryProvider {
@Override
public boolean canProvideFor(TypeUsage targetType) {
return targetType.isOfType(BugTest.GenericType.class);
}
@Override
public Set<Arbitrary<?>> provideFor(TypeUsage targetType, SubtypeProvider subtypeProvider) {
System.out.println("provideFor " + targetType.getType().getTypeName());
System.out.println("targetType=" + targetType);
TypeUsage innerType = targetType.getTypeArguments().get(0);
System.out.println("TypeArgument = " + innerType.getType());
var innerTypeProviders = subtypeProvider.apply(innerType);
if (innerTypeProviders.isEmpty())
throw new RuntimeException("Cannot find any Arbitrary provider for " + innerType.getType().getTypeName());
return innerTypeProviders.stream()
.map(arbitrary -> arbitrary.map(BugTest.GenericType::new))
.collect(Collectors.toSet());
}
}
}
} |
Judging by the amount of generics, https://github.com/harawata/typeparameterresolver might be relevant |
I've just tried it on my use case (lmartelli/jqwik-issue-492@de206e3) but it does not seem to provide more information. |
Thanks @lmartelli for the reproducing example. It's really helpfully and it strongly suggests a bug in jqwik's type resolution to me. I'll put the bug as first thing on my list for 1.7.5 since 1.7.4 will have to be released soonish in order to get the micronaut extension on the road. |
Next on my list for 1.8.0 |
Should be fixed. |
Reopen if it does not work for you. |
I have an
ArbitraryProvider
implementation use in a context of a hierarchy of abstract inner classes of an abstract test class like this (I will provide for a complete minimal "working" example, but this should give you a rough picture) :When
without_authority_returns_forbidden()
is run for GroupGetConfigurations
,provideFor()
fails withjava.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
because the type arguments are missing.The text was updated successfully, but these errors were encountered: