JVM_IR. Remove descriptors from ConstAndJvmFieldPropertiesLowering

This commit is contained in:
Georgy Bronnikov
2018-10-23 18:21:18 +03:00
parent 41da078de5
commit bba711a189
2 changed files with 3 additions and 12 deletions
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.common.lower.irBlock
import org.jetbrains.kotlin.backend.common.makePhase
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
@@ -20,7 +19,6 @@ import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.load.java.JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendContext) : IrElementTransformerVoid(), FileLoweringPass {
override fun lower(irFile: IrFile) {
@@ -28,7 +26,7 @@ class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendContext) : Ir
}
override fun visitProperty(declaration: IrProperty): IrStatement {
if (JvmCodegenUtil.isConstOrHasJvmFieldAnnotation(declaration.descriptor)) {
if (declaration.isConst || declaration.backingField?.hasAnnotation(JVM_FIELD_ANNOTATION_FQ_NAME) == true) {
/*Safe or need copy?*/
declaration.getter = null
declaration.setter = null
@@ -51,9 +49,6 @@ class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendContext) : Ir
assert(expression is IrSetterCallImpl)
substituteSetter(irProperty, expression)
}
} else if (irProperty.descriptor is SyntheticJavaPropertyDescriptor) {
expression.dispatchReceiver = expression.extensionReceiver
expression.extensionReceiver = null
}
return super.visitCall(expression)
}
@@ -71,7 +66,7 @@ class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendContext) : Ir
expression.origin,
expression.superQualifierSymbol
)
return buildSubstitution(backingField.isStaticField(), setExpr, receiver)
return buildSubstitution(backingField.isStatic, setExpr, receiver)
}
private fun substituteGetter(irProperty: IrProperty, expression: IrCall): IrExpression {
@@ -86,7 +81,7 @@ class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendContext) : Ir
expression.origin,
expression.superQualifierSymbol
)
return buildSubstitution(backingField.isStaticField(), getExpr, receiver)
return buildSubstitution(backingField.isStatic, getExpr, receiver)
}
private fun buildSubstitution(needBlock: Boolean, setOrGetExpr: IrFieldAccessExpression, receiver: IrExpression?): IrExpression {
@@ -112,6 +107,3 @@ class ConstAndJvmFieldPropertiesLowering(val context: CommonBackendContext) : Ir
}
}
}
// Should probably be an utility function with a more direct implementation.
private fun IrField.isStaticField() = (descriptor.dispatchReceiverParameter == null)
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.ir.declarations
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.types.IrType