diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt index b618818ea94..eef290d7361 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.isNothing import org.jetbrains.kotlin.ir.types.isUnit import org.jetbrains.kotlin.name.ClassId @@ -202,6 +203,16 @@ class DelegatedMemberGenerator( delegateFunction.valueParameters.forEach { putValueArgument(it.index, IrGetValueImpl(startOffset, endOffset, it.type, it.symbol)) } + superFunction.typeParameters.forEach { + putTypeArgument( + it.index, IrSimpleTypeImpl( + delegateFunction.typeParameters[it.index].symbol, + hasQuestionMark = false, + arguments = emptyList(), + annotations = emptyList() + ) + ) + } } if (superFunction.returnType.isUnit() || superFunction.returnType.isNothing()) { body.statements.add(irCall) diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt index b88faf4c614..3d4a764b356 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt @@ -55,7 +55,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt VALUE_PARAMETER name:b index:1 type:B of .Test1.foo BLOCK_BODY CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null - : + : B of .Test1.foo $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.foo' type=.Test1.Test1> origin=null a: GET_VAR 'a: E of .Test1 declared in .Test1.foo' type=E of .Test1 origin=null @@ -73,7 +73,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test1, C of .Test1.>? declared in .Test1' CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test1, C of .Test1.>? origin=null - : + : C of .Test1. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null $receiver: GET_VAR ': C of .Test1. declared in .Test1.' type=C of .Test1. origin=null @@ -90,7 +90,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): D of .Test1.? declared in .Test1' CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test1.? origin=null - : + : D of .Test1. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null $receiver: GET_VAR ': kotlin.collections.List.Test1.> declared in .Test1.' type=kotlin.collections.List.Test1.> origin=null @@ -104,7 +104,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt VALUE_PARAMETER name: index:0 type:D of .Test1.? BLOCK_BODY CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null - : + : D of .Test1. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null $receiver: GET_VAR ': kotlin.collections.List.Test1.> declared in .Test1.' type=kotlin.collections.List.Test1.> origin=null @@ -141,7 +141,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt VALUE_PARAMETER name:b index:1 type:B of .Test2.foo BLOCK_BODY CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null - : + : B of .Test2.foo $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null a: GET_VAR 'a: kotlin.String declared in .Test2.foo' type=kotlin.String origin=null @@ -159,7 +159,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test2.>? declared in .Test2' CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test2.>? origin=null - : + : C of .Test2. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': C of .Test2. declared in .Test2.' type=C of .Test2. origin=null @@ -176,7 +176,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): D of .Test2.? declared in .Test2' CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test2.? origin=null - : + : D of .Test2. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.collections.List.Test2.> declared in .Test2.' type=kotlin.collections.List.Test2.> origin=null @@ -190,7 +190,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt VALUE_PARAMETER name: index:0 type:D of .Test2.? BLOCK_BODY CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null - : + : D of .Test2. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.collections.List.Test2.> declared in .Test2.' type=kotlin.collections.List.Test2.> origin=null diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt index 9f16438211d..25803ef7550 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt @@ -17,20 +17,20 @@ class Test1 : IBase { } override fun foo(a: E, b: B) { - .#<$$delegate_0>.foo(a = a, b = b) + .#<$$delegate_0>.foo(a = a, b = b) } override val C.id: Map? override get(): Map? { - return (.#<$$delegate_0>, ).() + return (.#<$$delegate_0>, ).() } override var List.x: D? override get(): D? { - return (.#<$$delegate_0>, ).() + return (.#<$$delegate_0>, ).() } override set(: D?) { - (.#<$$delegate_0>, ).( = ) + (.#<$$delegate_0>, ).( = ) } local /* final field */ val <$$delegate_0>: IBase = i @@ -45,20 +45,20 @@ class Test2 : IBase { } override fun foo(a: String, b: B) { - .#<$$delegate_0>.foo(a = a, b = b) + .#<$$delegate_0>.foo(a = a, b = b) } override val C.id: Map? override get(): Map? { - return (.#<$$delegate_0>, ).() + return (.#<$$delegate_0>, ).() } override var List.x: D? override get(): D? { - return (.#<$$delegate_0>, ).() + return (.#<$$delegate_0>, ).() } override set(: D?) { - (.#<$$delegate_0>, ).( = ) + (.#<$$delegate_0>, ).( = ) } local /* final field */ val <$$delegate_0>: IBase = j diff --git a/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt b/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt index 595be85c87a..e0397a83172 100644 --- a/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/kt45934.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): @[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .C.foo?>? declared in .C' CALL 'public abstract fun foo (): @[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .I.foo?>? declared in .I' type=@[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .C.foo?>? origin=null - : + : C of .C.foo $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.I visibility:local [final]' type=.I origin=null receiver: GET_VAR ': .C declared in .C.foo' type=.C origin=null FIELD DELEGATE name:<$$delegate_0> type:.I visibility:local [final] diff --git a/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt b/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt index 53fac91195b..8946df8e6d0 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt @@ -43,7 +43,7 @@ FILE fqName: fileName:/kt35550.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): T of .A. declared in .A' CALL 'public open fun (): T of .I. declared in .I' type=T of .A. origin=null - : + : T of .A. $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.I visibility:local [final]' type=.I origin=null receiver: GET_VAR ': .A declared in .A.' type=.A origin=null $receiver: GET_VAR ': T of .A. declared in .A.' type=T of .A. origin=null diff --git a/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt b/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt index 1e4aa765a55..a8da794e1c7 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt @@ -15,7 +15,7 @@ class A : I { override val T.id: T override get(): T { - return (.#<$$delegate_0>, ).() + return (.#<$$delegate_0>, ).() } local /* final field */ val <$$delegate_0>: I = i diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.ir.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.ir.txt index ae7cb163774..fd032ea4022 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.ir.txt @@ -54,7 +54,7 @@ FILE fqName: fileName:/delegatedMembers.kt VALUE_PARAMETER name:x index:1 type:X of .Test.qux BLOCK_BODY CALL 'public abstract fun qux (t: T of .IBase, x: X of .IBase.qux): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null - : + : X of .Test.qux $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IBase.Test> visibility:local [final]' type=.IBase.Test> origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.qux' type=.Test.Test> origin=null t: GET_VAR 't: TT of .Test declared in .Test.qux' type=TT of .Test origin=null diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt index 85126984874..c8ffbebf8be 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt @@ -19,7 +19,7 @@ class Test : IBase { } override fun qux(t: TT, x: X) { - .#<$$delegate_0>.qux(t = t, x = x) + .#<$$delegate_0>.qux(t = t, x = x) } override val bar: Int