Proper implement 'classForImplicitThis'

This commit is contained in:
Mikhael Bogdanov
2019-07-18 14:47:57 +02:00
parent a9f0d1a53b
commit 74e49d91ca
9 changed files with 45 additions and 7 deletions
@@ -33,11 +33,14 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
private val IrValueSymbol.classForImplicitThis: IrClass?
// TODO: is this the correct way to get the class?
// -1 means value is either IMPLICIT or EXTENSION receiver
get() = if (this is IrValueParameterSymbol && owner.index == -1 && owner.name.isSpecial /* <this> */)
owner.type.classOrNull?.owner
else
null
get() =
if (this is IrValueParameterSymbol && owner.index == -1 &&
(owner == (owner.parent as? IrFunction)?.dispatchReceiverParameter ||
owner == (owner.parent as? IrClass)?.thisReceiver)
) {
owner.type.classOrNull?.owner
} else
null
override fun lower(irClass: IrClass) {
if (!irClass.isInner) return