[FIR] Make captureFromTypeParameterUpperBoundIfNeeded smarter

Before this change `ARGUMENT_TYPE_MISMATCH` would complain that
`Y` "is not a subtype of" `Inv<Y>`, because the function would only
check immediate bounds of the type parameter `Y`. `chosenSupertype`
would be `X`, not `Inv<out kotlin/String>`.

^KT-60056
This commit is contained in:
Nikolay Lunyak
2023-11-23 13:01:39 +02:00
committed by Space Team
parent 5e1e8e8f61
commit 69fba8d33b
10 changed files with 56 additions and 59 deletions
@@ -1,11 +0,0 @@
interface Inv<T>
fun <Y: X, X : Inv<out String>> foo(x: X, y: Y) {
val rX = bar(x)
rX.length
val rY = bar(<!ARGUMENT_TYPE_MISMATCH!>y<!>)
rY.<!UNRESOLVED_REFERENCE!>length<!>
}
fun <Y> bar(l: Inv<Y>): Y = TODO()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface Inv<T>
fun <Y: X, X : Inv<out String>> foo(x: X, y: Y) {