-
Notifications
You must be signed in to change notification settings - Fork 273
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
Generated 'from' method has trouble with parameterized interfaces that declare properties #1506
Comments
It may be a little bit weird, so what it does, it consider each supertype and then the same type and uses runtime bits to avoid pulling things already set. It doesn't do good analysis of what properties subtypes are covered and which are not (again - runtime check). And I don't remember for sure, but we're probably skipping supertypes with Generic parameters to avoid unsoundness/heap pollution. In the given example, it seems clear that the check like |
Thanks so much for looking at this. In the meantime, we refactored our code to avoid this specific problem, so we are not in a rush to get it fixed. But it feels like a pitfall other users might run into as well, even if it is a bit of an edge case. |
Hi, we use Immutables and love it, but recently ran into what feels like a bug.
We declare some properties on mixin interfaces so they can be shared among related types, and use
from(otherImpl)
liberally to copy all relevant properties between the different sub-types. In some cases, we parameterize the typesMixin<Self extends Mixin<Self>>
in order to give proper return types toSelf withProperty()
methods.However, this seems to break the
from()
method in some cases. Consider:Expected:
Since both
ImplA
andImplB
extendLastModified
, and while the parameterization of the type is different, it does not affect the property in any way, I would expect thefrom
method to copy the property.Actual:
The generated
ImmutableImplBBuilder.from
method unfortunately seems to not be correct.Since ImplB already implements Property, the two
instanceof
clauses are redundant. The second check should probably check forobject instanceof LastModified
.The text was updated successfully, but these errors were encountered: