You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which yields this error in the static create method: error: incompatible types: Factory<MyFactory_Impl> cannot be converted to Provider<MyFactory>.
This seems like a type inference issue because this can be fixed by explicitly setting the generic type of InstanceFactory.create like so: return InstanceFactory.<MyFactory>create(new MyFactory_Impl(delegateFactory));
(or casting MyFactory_Impl, or a few other tricks).
I feel like this should work, but am I also doing something wrong?
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. I think you're right that this is likely a type inference issue that works with java 8 but has issues with java 7. I'll look into fixing this for the next release.
To test this, I've updated our gradle tests to allow inputing a Java version as a cmd-line argument, and I've added a regression test for this issue.
Fixes#2309
RELNOTES=Fixes#2309: Fixes type inference issues with generated assisted factory in Java 7.
PiperOrigin-RevId: 354200817
To test this, I've updated our gradle use sourceCompatibility = VERSION_1_7.
Fixes#2309
RELNOTES=Fixes#2309: Fixes type inference issues with generated assisted factory in Java 7.
PiperOrigin-RevId: 354200817
Given this setup
The following Factory implementation is created
Which yields this error in the static
create
method:error: incompatible types: Factory<MyFactory_Impl> cannot be converted to Provider<MyFactory>
.This seems like a type inference issue because this can be fixed by explicitly setting the generic type of
InstanceFactory.create
like so:return InstanceFactory.<MyFactory>create(new MyFactory_Impl(delegateFactory));
(or casting MyFactory_Impl, or a few other tricks).
I feel like this should work, but am I also doing something wrong?
The text was updated successfully, but these errors were encountered: