K2: Fix deserialization of upper bound of type parameter in nested class

Previously, containingDeclarationSymbol for V was set to the outer class
BaseRoot, so its upper bounds was computed to the ones from TNested
at org.jetbrains.kotlin.fir.resolve.calls.CreateFreshTypeVariableSubstitutorStageKt.getTypeParameterFromExpandedClass

^KT-56706 Fixed
This commit is contained in:
Denis.Zharkov
2023-02-17 18:24:23 +01:00
committed by Space Team
parent 9f51d3fbeb
commit 0c9fad87c3
15 changed files with 100 additions and 2 deletions
@@ -0,0 +1,27 @@
// ISSUE: KT-56706
// MODULE: lib
// FILE: lib.kt
package lib
abstract class BaseRoot<TNested : BaseRoot.BaseNested<*>> {
open class BaseNested<V>(val box: V)
}
// MODULE: main(lib)
// FILE: main.kt
package main
import lib.BaseRoot
class Foo(val v: String)
class ImplRoot : BaseRoot<ImplRoot.ImplNested>() {
class ImplNested: BaseNested<Foo>(box = Foo("OK")) {
fun bar(): String {
return BaseNested(box).box.v // K1 doesn't report it, yet message is really strange
// "actual type is main/Foo but lib/BaseRoot.BaseNested<*> was expected" which is also strange, since type of box is main/Foo and V for argument
}
}
}
fun box(): String = ImplRoot.ImplNested().bar()