backend: Don't process FAKE_OVERRIDE properties in lateinit lowering
This commit is contained in:
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.konan.isValueType
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
@@ -37,7 +38,7 @@ internal class LateinitLowering(val context: CommonBackendContext): FileLowering
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.transformChildrenVoid(object: IrElementTransformerVoid() {
|
||||
override fun visitProperty(declaration: IrProperty): IrStatement {
|
||||
if (declaration.descriptor.isLateInit)
|
||||
if (declaration.descriptor.isLateInit && declaration.descriptor.kind.isReal)
|
||||
transformGetter(declaration.backingField!!.symbol, declaration.getter!!)
|
||||
return declaration
|
||||
}
|
||||
|
||||
@@ -829,6 +829,11 @@ task lateinit_notInitialized(type: RunKonanTest) {
|
||||
source = "codegen/lateinit/notInitialized.kt"
|
||||
}
|
||||
|
||||
task lateinit_inBaseClass(type: RunKonanTest) {
|
||||
goldValue = "42\n"
|
||||
source = "codegen/lateinit/inBaseClass.kt"
|
||||
}
|
||||
|
||||
task coroutines_simple(type: RunKonanTest) {
|
||||
goldValue = "42\n"
|
||||
source = "codegen/coroutines/simple.kt"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class A(val a: Int)
|
||||
|
||||
open class B {
|
||||
lateinit var a: A
|
||||
}
|
||||
|
||||
class C: B() {
|
||||
fun foo() { a = A(42) }
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val c = C()
|
||||
c.foo()
|
||||
println(c.a.a)
|
||||
}
|
||||
Reference in New Issue
Block a user