JVM IR: fix incorrect IR types in inner and enum class lowerings
In InnerClassesLowering, the type of the "outer$0" expression should be the outer class, not the inner class. In EnumClassLowering, the type of the enum entry is the type of its class or the type of the enum class, but not the type of initialierExpression which is always Unit
This commit is contained in:
committed by
Alexander Udalov
parent
4bfa98144b
commit
8b395589be
+1
-8
@@ -141,14 +141,7 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val outerThisField = context.declarationFactory.getOuterThisField(innerClass)
|
val outerThisField = context.declarationFactory.getOuterThisField(innerClass)
|
||||||
irThis = IrGetFieldImpl(
|
irThis = IrGetFieldImpl(startOffset, endOffset, outerThisField.symbol, outerThisField.type, irThis, origin)
|
||||||
startOffset,
|
|
||||||
endOffset,
|
|
||||||
outerThisField.symbol,
|
|
||||||
innerClass.defaultType,
|
|
||||||
irThis,
|
|
||||||
origin
|
|
||||||
)
|
|
||||||
|
|
||||||
val outer = innerClass.parent
|
val outer = innerClass.parent
|
||||||
innerClass = outer as? IrClass ?:
|
innerClass = outer as? IrClass ?:
|
||||||
|
|||||||
+4
-3
@@ -195,13 +195,14 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP
|
|||||||
return enumEntryClass
|
return enumEntryClass
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createFieldForEnumEntry(enumEntry: IrEnumEntry): IrField {
|
private fun createFieldForEnumEntry(enumEntry: IrEnumEntry): IrField =
|
||||||
return context.declarationFactory.getFieldForEnumEntry(enumEntry, enumEntry.initializerExpression!!.type).also {
|
context.declarationFactory.getFieldForEnumEntry(
|
||||||
|
enumEntry, (enumEntry.correspondingClass ?: enumEntry.parentAsClass).defaultType
|
||||||
|
).also {
|
||||||
it.initializer = IrExpressionBodyImpl(enumEntry.initializerExpression!!)
|
it.initializer = IrExpressionBodyImpl(enumEntry.initializerExpression!!)
|
||||||
enumEntryFields.add(it)
|
enumEntryFields.add(it)
|
||||||
enumEntriesByField[it] = enumEntry
|
enumEntriesByField[it] = enumEntry
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupSynthesizedEnumClassMembers() {
|
private fun setupSynthesizedEnumClassMembers() {
|
||||||
val irField = createSyntheticValuesFieldDeclaration()
|
val irField = createSyntheticValuesFieldDeclaration()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
open class A {
|
open class A {
|
||||||
open val foo: String = "OK"
|
open val foo: String = "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
interface BK {
|
interface BK {
|
||||||
fun foo(): String
|
fun foo(): String
|
||||||
fun bar(): String
|
fun bar(): String
|
||||||
|
|||||||
Reference in New Issue
Block a user