-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 inference broken in 6.9.0 #5522
Comments
Note that the workaround this issue is to either not process related elements generically or relax typing which isn't desirable and goes against the philosophy of the client. |
@manusa @metacosm two thoughts. It could be unrelated but it could be worth seeing the split package that was introduced - #5520 - could be contributing. Could you try to move at least Pluralize moved to common and see if that helps. The other thought is that the resource does not actually need to implement Editable to expose these methods - that was done for the sundrio logic that is creating Builders, but that can just fall through to the lookup tables. |
I'm trying to but I'm unable to reproduce this. #5520 needs to get solved anyway, could you please create the PR with the fix? I'll try to release snapshots after merging. |
Yeah, that does look suspicious. The |
Added a test that should exhibit the issue. |
@metacosm observations based upon the test:
or
Let me try backing out the change that added the edit method. |
I can't really figure out what makes this test different to the one I proposed in the internal chat, hence why one fails and the other doesn't.
It's interesting that the method reference works. With |
In my case, running from the command-line (Java 8 from kubernetes-client-api directory) is still not failing. Update It does fail with Java11 and Java17, so it definitely might have something to do with modules. |
Doesn't indeed appear to change anything.
It doesn't work in my IDE here, or at least, the original issue in JOSDK showed up in my IDE.
In both cases, though, this is a wider type than what would be expected. The more specific common type should be
|
Yes, the thing that makes it fail is
I think that's expected because it's basically telling Java to consider all elements as
|
I wasn't trying to be overly narrow, just using the class where the resolve method is introduced. I understand that it should work without the typing. I expanded the test to inline definitions of an AltConfigMap and AltDeployment along with dummy builders. Based upon that the next observations are:
Further inlining all of the builder package with the test shows:
So I think there's a viable workaround by removing the Editable interface from the resources (but the edit / toBuilder methods can stay) - however there just seems to be something pretty funky about the sundrio typing that is confusing the compiler. I'll poke around a little more and see if there are any changes that could be made to BaseFluent to resolve this. |
I was thinking that indeed the error might have come from an interface being implemented twice with different type constraints… |
Similar problem is still ongoing in 6.9.3 (Sundrio 0.101.3) Quarkus build reports:
Triggered at: for (Decorator d : sortDecorators(union)) {
log("Applying decorator '%s'", d.getClass().getName());
groups.get(group).accept(d);
}
} |
Indeed seeing this type of errors as well in QOSDK. |
Description
(From internal conversation with @iocanel and @metacosm)
PR #5138, in scope of #5135, provided changes to make Resources
Editable
.While this improvement allows for one line edit operations similar to what Lombok's
toBuilder
does, it has somehow broken type inference in some scenarios.One such scenario is where you have elements that are parameterized as such:
A<R extends HasMetadata, P>
. If you have several such objects which all have the same value forP
but different values forR
and you want to process them as a list.Before 6.9.0, the list was correctly inferred to be a list containing elements of type
A<? extends HasMetadata, P>
.With 6.9.0, the list is now inferred to contain elements of type
A<? extends Editable<? extends BaseFluent<? extends BaseFluent<?>>>, P>
.With type erasure, this results in hard-to-diagnose errors because they occur outside of the user's code, similar to:
You can see such an error here: https://github.com/operator-framework/java-operator-sdk/actions/runs/6456675029/job/17526638395#step:5:2605
If you look at the code, you'll see that none of the classes or method mentioned in the error are used, which makes for a very unpleasant diagnosing experience.
The text was updated successfully, but these errors were encountered: