JVM: do not put public field access into a single expression block
It affects the `is IrGetField` check in TypeOperatorLowering.computeNotNullAssertionText, which leads to missing NPE messages when accessing backing fields of public properties. #KT-64615
This commit is contained in:
committed by
Space Team
parent
96b2f13397
commit
f01e633f8b
+4
-1
@@ -136,9 +136,12 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass
|
||||
} else {
|
||||
+irGetField(receiver.takeUnless { backingField.isStatic }, backingField)
|
||||
}
|
||||
}
|
||||
}.unwrapSingleExpressionBlock()
|
||||
}
|
||||
|
||||
private fun IrExpression.unwrapSingleExpressionBlock(): IrExpression =
|
||||
(this as? IrBlock)?.statements?.singleOrNull() as? IrExpression ?: this
|
||||
|
||||
override fun visitWhen(expression: IrWhen, data: IrDeclaration?): IrExpression {
|
||||
val isCompilerGenerated = expression.origin == null
|
||||
expression.transformChildren(this, data)
|
||||
|
||||
Reference in New Issue
Block a user