diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 2abd3a2743b..af7a523537f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -25344,6 +25344,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index ce07fa4515b..8e4989b1fd0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -1346,6 +1346,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/kt37779.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/ir/irText/expressions/kt45022.kt"); + } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt index fa7f1e62144..e6369b53bf4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.PropertyImportedFromObject import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic +import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject import org.jetbrains.kotlin.types.KotlinType class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { @@ -206,6 +207,8 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen createVariableValue(ktExpr, descriptor, origin) is PropertyDescriptor -> generateAssignmentReceiverForProperty(descriptor, origin, ktExpr, resolvedCall, isAssignmentStatement) + is FakeCallableDescriptorForObject -> + OnceExpressionValue(ktExpr.genExpr()) is ValueDescriptor -> createVariableValue(ktExpr, descriptor, origin) else -> diff --git a/compiler/testData/codegen/box/operatorConventions/kt45022.kt b/compiler/testData/codegen/box/operatorConventions/kt45022.kt new file mode 100644 index 00000000000..10c2ea64f7d --- /dev/null +++ b/compiler/testData/codegen/box/operatorConventions/kt45022.kt @@ -0,0 +1,8 @@ +fun box(): String { + X += 1 + return "OK" +} + +object X { + operator fun plusAssign(any: Any) = Unit +} diff --git a/compiler/testData/ir/irText/expressions/kt45022.fir.txt b/compiler/testData/ir/irText/expressions/kt45022.fir.txt new file mode 100644 index 00000000000..da052287a6f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt45022.fir.txt @@ -0,0 +1,35 @@ +FILE fqName: fileName:/kt45022.kt + TYPEALIAS name:AX visibility:public expandedType:.X + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=null + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=null + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X + CONSTRUCTOR visibility:private <> () returnType:.X [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:plusAssign visibility:public modality:FINAL <> ($this:.X, any:kotlin.Any) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.X + VALUE_PARAMETER name:any index:0 type:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + 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 [operator] 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 diff --git a/compiler/testData/ir/irText/expressions/kt45022.kt b/compiler/testData/ir/irText/expressions/kt45022.kt new file mode 100644 index 00000000000..b8fd8d7083b --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt45022.kt @@ -0,0 +1,12 @@ +// SKIP_KT_DUMP + +typealias AX = X + +fun test() { + X += 1 + AX += 1 +} + +object X { + operator fun plusAssign(any: Any) = Unit +} diff --git a/compiler/testData/ir/irText/expressions/kt45022.txt b/compiler/testData/ir/irText/expressions/kt45022.txt new file mode 100644 index 00000000000..7809e75f226 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt45022.txt @@ -0,0 +1,35 @@ +FILE fqName: fileName:/kt45022.kt + TYPEALIAS name:AX visibility:public expandedType:.X + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=PLUSEQ + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=PLUSEQ + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X + CONSTRUCTOR visibility:private <> () returnType:.X [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:plusAssign visibility:public modality:FINAL <> ($this:.X, any:kotlin.Any) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.X + VALUE_PARAMETER name:any index:0 type:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + 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 [operator] 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 diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index a54c619c34d..a636d7b31ba 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -25344,6 +25344,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index b145c3735d4..11d91fb81ae 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -25344,6 +25344,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index ceff6e39e78..a1a4dc7681f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -1346,6 +1346,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/expressions/kt37779.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/ir/irText/expressions/kt45022.kt"); + } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 5f14b1c8bea..09a84c914c0 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -21544,6 +21544,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 683bca7103b..491dcd822bb 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -17204,6 +17204,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 860b8daad47..fda916303a0 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -16689,6 +16689,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index ffa34fb50c2..67e5a2ac3f2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -16754,6 +16754,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index bb1aae8e6a8..6a54105c50d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -10520,6 +10520,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt");