-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ArC fails to construct bean with self-referencing generic constraint #17147
Comments
Hi @Felk, thanks for reporting this problem. It's a known issue - see also smallrye/jandex#88 and we can't do much until this jandex issue is resolved. |
Thanks for letting me know, I'll watch that issue |
@Ladicek would you care to take a look at the ArC part? You fixed the Jandex issue, hence a perfect candidate 😉 . |
Sure thing! |
So the reproducer actually builds and runs just fine (I believe due to #27631), but I can't inject the produced bean anywhere, nor can I look it up programmatically -- and I don't even have an idea how to express such injection or programmatic lookup. I'm trying this: @Dependent
static class Producer {
@Produces
@Dependent
public <T extends Comparable<T>> List<T> produce() {
return new ArrayList<>();
}
}
// inject
@Dependent
static class Target<T extends Comparable<T>> {
@Inject
List<T> list;
public List<T> getList() {
return list;
}
}
// lookup
public <T extends Comparable<T>> void test() {
ArcContainer arc = Arc.container();
InstanceHandle<List<T>> handle = arc.instance(new TypeLiteral<List<T>>() {});
} But I'm not exactly sure if that's supposed to work or not. Any opinions? :-) |
In my original usecase I think I injected a concrete type, e.g. @Inject
List<String> stringList; |
Yeah, I originally thought about that, but I'm not sure that's supposed to work as well. If I'm reading Assignability of raw and parameterized types, it probably should. It currently doesn't, because our My attempts in the previous comment are most likely wrong, because those |
ArC appears to be unable to generate beans if they have a generic parameter and a constraint referencing the generic parameter, as is common for e.g.
T extends Comparable<T>
. The issue can be reproduced as follows:which results in the following error at build time:
with a prettyfied error message:
A few more examples:
<T extends List<T>>
<T extends Serializable>
<T>
I have attached a sample project to reproduce the problem: arc-selfreferencing-generic-constraint.zip
The text was updated successfully, but these errors were encountered: