JVM IR: fix compound access to JvmField properties
This commit is contained in:
committed by
Alexander Udalov
parent
5c807266f6
commit
4bfa98144b
+3
-3
@@ -61,13 +61,13 @@ private class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendConte
|
||||
|
||||
private fun substituteSetter(irProperty: IrProperty, expression: IrCall): IrExpression {
|
||||
val backingField = irProperty.backingField!!
|
||||
val receiver = expression.dispatchReceiver?.let { super.visitExpression(it) }
|
||||
val receiver = expression.dispatchReceiver?.transform(this, null)
|
||||
val setExpr = IrSetFieldImpl(
|
||||
expression.startOffset,
|
||||
expression.endOffset,
|
||||
backingField.symbol,
|
||||
receiver,
|
||||
super.visitExpression(expression.getValueArgument(expression.valueArgumentsCount - 1)!!),
|
||||
expression.getValueArgument(expression.valueArgumentsCount - 1)!!.transform(this, null),
|
||||
expression.type,
|
||||
expression.origin,
|
||||
expression.superQualifierSymbol
|
||||
@@ -77,7 +77,7 @@ private class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendConte
|
||||
|
||||
private fun substituteGetter(irProperty: IrProperty, expression: IrCall): IrExpression {
|
||||
val backingField = irProperty.backingField!!
|
||||
val receiver = expression.dispatchReceiver?.let { super.visitExpression(it) }
|
||||
val receiver = expression.dispatchReceiver?.transform(this, null)
|
||||
val getExpr = IrGetFieldImpl(
|
||||
expression.startOffset,
|
||||
expression.endOffset,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
class A {
|
||||
@JvmField val b = B()
|
||||
}
|
||||
|
||||
class B {
|
||||
@JvmField val c = C()
|
||||
|
||||
@JvmField val result = "OK"
|
||||
}
|
||||
|
||||
class C {
|
||||
@JvmField var d = "Fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
a.b.c.d = a.b.result
|
||||
return a.b.c.d
|
||||
}
|
||||
+5
@@ -14333,6 +14333,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/jvmField/classFieldReflection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compoundAccess.kt")
|
||||
public void testCompoundAccess() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/compoundAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorProperty.kt")
|
||||
public void testConstructorProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/constructorProperty.kt");
|
||||
|
||||
+5
@@ -14333,6 +14333,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/jvmField/classFieldReflection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compoundAccess.kt")
|
||||
public void testCompoundAccess() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/compoundAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorProperty.kt")
|
||||
public void testConstructorProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/constructorProperty.kt");
|
||||
|
||||
+5
@@ -14338,6 +14338,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/jvmField/classFieldReflection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compoundAccess.kt")
|
||||
public void testCompoundAccess() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/compoundAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorProperty.kt")
|
||||
public void testConstructorProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvmField/constructorProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user