[FIR2IR] Properly calculate the type of delegated function call

```
interface A {
    fun <T> foo(): T
}

class B(val a: A) : A by A {
    generated fun <T'> foo(): T' {
        return a.foo() // <------
    }
}
```

There was a problem that type of generated delegated call used
  an unsubstituted type of the original delegated declaration, which led
  to a situation when (see example) type of call `a.foo()` was not `T'`
  but `T`, which led to incorrect IR and further exceptions on backend

^KT-64257 Fixed
^KT-64284 Obsolete
This commit is contained in:
Dmitriy Novozhilov
2023-12-14 17:39:41 +02:00
committed by Space Team
parent c48753900c
commit 94c46d384a
28 changed files with 206 additions and 148 deletions
@@ -207,7 +207,7 @@ FILE fqName:<root> fileName:/delegatedPropertyWithMultipleOverriddens_generics.k
$this: VALUE_PARAMETER name:<this> type:<root>.MC
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.MC'
CALL 'public open fun foo (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=E6 of <root>.MyArrayList origin=null
CALL 'public open fun foo (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.MyArrayList<kotlin.String> visibility:private [final]' type=<root>.MyArrayList<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.MC declared in <root>.MC.foo' type=<root>.MC origin=null
PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val]
@@ -220,7 +220,7 @@ FILE fqName:<root> fileName:/delegatedPropertyWithMultipleOverriddens_generics.k
$this: VALUE_PARAMETER name:<this> type:<root>.MC
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-bar> (): kotlin.String declared in <root>.MC'
CALL 'public open fun <get-bar> (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=E6 of <root>.MyArrayList origin=null
CALL 'public open fun <get-bar> (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.MyArrayList<kotlin.String> visibility:private [final]' type=<root>.MyArrayList<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.MC declared in <root>.MC.<get-bar>' type=<root>.MC origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]