public abstract class GenericBase<T> {
public abstract T generic();
public abstract static class Builder<T, R extends GenericBase<T>, B extends Builder<T, R, B>> {
public abstract B generic(T generic);
protected abstract R autoBuild();
}
}
And autovalue class that uses it
@GenerateTypeAdapter
@AutoValue
public abstract class AddressGenericBase extends GenericBase<Address> {
public abstract String topLevelNonGeneric();
@AutoValue.Builder public abstract static class Builder
extends GenericBase.Builder<Address, AddressGenericBase, Builder> {
public abstract Builder topLevelNonGeneric(String topLevel);
}
}
This is due to use not using the propertyTypes() API from extensions, so we try to write type variables rather than their materialized types. The fix is to use the propertyTypes() API for this. Note that we'll need to make a couple adjustments to how builder methods are looked up, as they still try to match based on the return type since they override the source ExecutableElement.
The following code will fail to build.
Given a generic base class
And autovalue class that uses it
This is due to use not using the
propertyTypes()
API from extensions, so we try to write type variables rather than their materialized types. The fix is to use thepropertyTypes()
API for this. Note that we'll need to make a couple adjustments to how builder methods are looked up, as they still try to match based on the return type since they override the sourceExecutableElement
.