PSI2IR KT-45022 object in LHS of compound assignment

This commit is contained in:
Dmitry Petrov
2021-02-18 17:18:10 +03:00
parent 05447ce0c8
commit 744a0fcd25
15 changed files with 148 additions and 0 deletions
@@ -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 {
@@ -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 {
@@ -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 ->
@@ -0,0 +1,8 @@
fun box(): String {
X += 1
return "OK"
}
object X {
operator fun plusAssign(any: Any) = Unit
}
+35
View File
@@ -0,0 +1,35 @@
FILE fqName:<root> fileName:/kt45022.kt
TYPEALIAS name:AX visibility:public expandedType:<root>.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 <root>.X' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.X
any: CONST Int type=kotlin.Int value=1
CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in <root>.X' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.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:<this> type:<root>.X
CONSTRUCTOR visibility:private <> () returnType:<root>.X [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [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:<root>.X, any:kotlin.Any) returnType:kotlin.Unit [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.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 <root>.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:<this> 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:<this> 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:<this> type:kotlin.Any
+12
View File
@@ -0,0 +1,12 @@
// SKIP_KT_DUMP
typealias AX = X
fun test() {
X += 1
AX += 1
}
object X {
operator fun plusAssign(any: Any) = Unit
}
+35
View File
@@ -0,0 +1,35 @@
FILE fqName:<root> fileName:/kt45022.kt
TYPEALIAS name:AX visibility:public expandedType:<root>.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 <root>.X' type=kotlin.Unit origin=PLUSEQ
$this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.X
any: CONST Int type=kotlin.Int value=1
CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in <root>.X' type=kotlin.Unit origin=PLUSEQ
$this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.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:<this> type:<root>.X
CONSTRUCTOR visibility:private <> () returnType:<root>.X [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [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:<root>.X, any:kotlin.Any) returnType:kotlin.Unit [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.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 <root>.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:<this> 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:<this> 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:<this> type:kotlin.Any
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");