diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index 253681e4aa7..ef64bc0e2f5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -2892,6 +2892,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI runTest("compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt"); } + @Test + @TestMetadata("substitutionOverrideWithDelegate.kt") + public void testSubstitutionOverrideWithDelegate() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt"); + } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index c2db7c5305c..d5c348c2343 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -2892,6 +2892,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { runTest("compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt"); } + @Test + @TestMetadata("substitutionOverrideWithDelegate.kt") + public void testSubstitutionOverrideWithDelegate() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt"); + } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception { diff --git a/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.ir.txt b/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.ir.txt new file mode 100644 index 00000000000..73b9be947fb --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.ir.txt @@ -0,0 +1,131 @@ +FILE fqName: fileName:/substitutionOverrideWithDelegate.kt + FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Unit declared in ' + CALL 'public open fun invoke (): kotlin.Unit declared in .DelegatedB' type=kotlin.Unit origin=INVOKE + $this: CONSTRUCTOR_CALL 'public constructor () declared in .DelegatedB' type=.DelegatedB origin=null + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:invoke visibility:public modality:OPEN <> ($this:.A) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.A + BLOCK_BODY + FUN name:invoke visibility:public modality:OPEN <> ($this:.A, value:kotlin.String) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:value index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun invoke (value: kotlin.String): kotlin.Unit declared in .A' + CALL 'public final fun bar (value: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR ': .A declared in .A.invoke' type=.A origin=null + value: GET_VAR 'value: kotlin.String declared in .A.invoke' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:bar visibility:public modality:FINAL <> ($receiver:.A, value:kotlin.String) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:value index:0 type:kotlin.String + BLOCK_BODY + CLASS CLASS name:DelegatedB modality:OPEN visibility:public superTypes:[.B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DelegatedB + CONSTRUCTOR visibility:public <> () returnType:.DelegatedB [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DelegatedB modality:OPEN visibility:public superTypes:[.B]' + FIELD DELEGATE name:$$delegate_0 type:.C visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () declared in .C' type=.C origin=null + : kotlin.String + FUN DELEGATED_MEMBER name:invoke visibility:public modality:OPEN <> ($this:.DelegatedB) returnType:kotlin.Unit [operator] + overridden: + public open fun invoke (): kotlin.Unit declared in .B + $this: VALUE_PARAMETER name: type:.DelegatedB + BLOCK_BODY + CALL 'public open fun invoke (): kotlin.Unit declared in .C' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.C visibility:private [final]' type=.C origin=null + receiver: GET_VAR ': .DelegatedB declared in .DelegatedB.invoke' type=.DelegatedB origin=null + FUN DELEGATED_MEMBER name:invoke visibility:public modality:OPEN <> ($this:.DelegatedB, value:kotlin.String) returnType:kotlin.Unit [operator] + overridden: + public open fun invoke (value: kotlin.String): kotlin.Unit declared in .B + $this: VALUE_PARAMETER name: type:.DelegatedB + VALUE_PARAMETER name:value index:0 type:kotlin.String + BLOCK_BODY + CALL 'public open fun invoke (value: kotlin.String): kotlin.Unit declared in .C' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.C visibility:private [final]' type=.C origin=null + receiver: GET_VAR ': .DelegatedB declared in .DelegatedB.invoke' type=.DelegatedB origin=null + value: GET_VAR 'value: kotlin.String declared in .DelegatedB.invoke' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B.B> + TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] reified:false + FUN FAKE_OVERRIDE name:invoke visibility:public modality:OPEN <> ($this:.A) returnType:kotlin.Unit [fake_override,operator] + overridden: + public open fun invoke (): kotlin.Unit declared in .A + $this: VALUE_PARAMETER name: type:.A + FUN FAKE_OVERRIDE name:invoke visibility:public modality:OPEN <> ($this:.A, value:kotlin.String) returnType:kotlin.Unit [fake_override,operator] + overridden: + public open fun invoke (value: kotlin.String): kotlin.Unit declared in .A + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:value index:0 type:kotlin.String + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.B.C>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C.C> + TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> () returnType:.C.C> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.B.C>]' + FUN FAKE_OVERRIDE name:invoke visibility:public modality:OPEN <> ($this:.A) returnType:kotlin.Unit [fake_override,operator] + overridden: + public open fun invoke (): kotlin.Unit declared in .B + $this: VALUE_PARAMETER name: type:.A + FUN FAKE_OVERRIDE name:invoke visibility:public modality:OPEN <> ($this:.A, value:kotlin.String) returnType:kotlin.Unit [fake_override,operator] + overridden: + public open fun invoke (value: kotlin.String): kotlin.Unit declared in .B + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:value index:0 type:kotlin.String + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt b/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt new file mode 100644 index 00000000000..c1e0cc3b9b0 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt @@ -0,0 +1,20 @@ +// WITH_STDLIB +// TARGET_BACKEND: JVM +// ISSUE: KT-61443 +// SKIP_SIGNATURE_DUMP + +fun foo() = DelegatedB()() + +interface A { + operator fun invoke() {} + + operator fun invoke(value: String) = bar(value) +} + +fun A.bar(value: String) {} + +open class DelegatedB : B by C() + +interface B : A + +class C : B diff --git a/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt.txt b/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt.txt new file mode 100644 index 00000000000..79b43abd13e --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt.txt @@ -0,0 +1,47 @@ +fun foo() { + return DelegatedB().invoke() +} + +interface A { + operator fun invoke() { + } + + operator fun invoke(value: String) { + return .bar(value = value) + } + +} + +fun A.bar(value: String) { +} + +open class DelegatedB : B { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: C = C() + override operator fun invoke() { + .#$$delegate_0.invoke() + } + + override operator fun invoke(value: String) { + .#$$delegate_0.invoke(value = value) + } + +} + +interface B : A { + +} + +class C : B { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 54f9116e2e9..535be3d4d76 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -2892,6 +2892,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest runTest("compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt"); } + @Test + @TestMetadata("substitutionOverrideWithDelegate.kt") + public void testSubstitutionOverrideWithDelegate() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/substitutionOverrideWithDelegate.kt"); + } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception {