Closed stevenschlansker closed 2 years ago
Oh, I see the problem now. I deleted the previous 2 messages I wrote, as they were just me being confused, nothing useful. But I think the provided test case doesn't trigger the described bug, there's got to be a wildcard somewhere to capture. But no matter, I understand the issue... I'll see what I can do.
The default TypeVisitor
was trying to be too smart... I simplified its behavior in regards to capture types.
Additionally, I implemented a method doing exactly (I think) what you need: GenericTypeReflector#reduceBounded
. It reduces all bounded types (variables, wildcards & captures) to their first bound. I actually want to use this this exact same thing in GraphQL SPQR instead of the current (flaky) custom implementation not relying on transform
😅
Released v1.3.13 with this.
Thank you so much! The reduceBounded
method seems to do exactly what I need. Jdbi now has much better type handling :smile_cat:
Hi @kaqqao thank you for your continued help, I wonder what you think of this.
Given the class,
I want to figure out the most specific type for the return value of
getProperty
given that I don't have the parameterizedGenericBean<T>
, onlyGenericBean.class
- replacingT
withString
(the bound) and then figure outList<String>
as the property type.To do this, I am trying to use
GenericTypeReflector.transform
and overridevisitVariable
to replace variables with their bound.Unfortunately, despite this being statically safe, it does not actually work:
It looks like the visitor assumes it can cast the result:
Please let me know if I'm on the wrong track, or if there's something I'm missing. Thank you!