-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
JavaConfig bean resolution fails with generics + Kotlin declaration-site variance #22313
Comments
In the end in java code it is translated to The only solution is to have kotlinized version of |
See also #20494 even more popular use case on collections. |
Let's try to tackle that in parallel of #24033 since there may be some links related to type with resolved bounds. The fix implementation should not be tied to Kotlin (but we will introduce Kotlin tests for that). |
Reopening as I mixed-up issue numbers in a recent commit message. |
I have added the repro as a unit test here. With declaration-site variance, there is a type mismatch in
|
I am waiting a feedback from Kotlin team, so I will move this issue to M3. |
Kotlin team is on PTO, so I have to move this issue to RC1 (tentatively). |
Kotlin team confirmed my proposal to resolve generic types with variance make sense, |
After a deeper look, it looks like we are going to need to leverage Kotlin reflection in either We need to compare the use-side variance (available on both Java and Kotlin) to declaration-site variance (available only via Kotlin reflection). The Kotlin team has confirmed there is no way to get a |
I move this issue to |
This reverts commit f075120. See spring-projectsgh-22313 See spring-projectsgh-31690
Declaration-site variance used in the very common
kotlin.Pair
class seems to impact bean resolution and currently prevents bean resolution to work as expected by the end user.Based on an original report on Twitter, I have created a more focused repro project.
Following test works with
class Tuple<A, B>
but fails withclass Tuple<out A, out B>
, which is pretty hard to diagnose when the user is usingkotlin.Pair
which is provided in Kotlin standard library.@jhoeller Do you think there is something to refine in our bean resolution algorithm to support this kind of Kotlin declaration-site variance?
The text was updated successfully, but these errors were encountered: