Change extension receiver this access to be a parameter access

This commit is contained in:
Tamas Vajk
2022-03-16 15:41:19 +01:00
committed by Ian Lynagh
parent 21f6867cd4
commit b26044b327
9 changed files with 67 additions and 31 deletions

View File

@@ -2247,7 +2247,7 @@ open class KotlinFileExtractor(
is IrGetValue -> {
val exprParent = parent.expr(e, callable)
val owner = e.symbol.owner
if (owner is IrValueParameter && owner.index == -1) {
if (owner is IrValueParameter && owner.index == -1 && !owner.isExtensionReceiver()) {
val id = tw.getFreshIdLabel<DbThisaccess>()
val type = useType(e.type)
val locId = tw.getLocation(e)
@@ -2294,7 +2294,10 @@ open class KotlinFileExtractor(
tw.writeCallableEnclosingExpr(id, callable)
tw.writeStatementEnclosingExpr(id, exprParent.enclosingStmt)
val vId = useValueDeclaration(owner)
val vId = if (owner is IrValueParameter && owner.isExtensionReceiver())
useValueParameter(owner, useFunction(owner.parent as IrFunction))
else
useValueDeclaration(owner)
tw.writeVariableBinding(id, vId)
}
}
@@ -2570,6 +2573,11 @@ open class KotlinFileExtractor(
}
}
private fun IrValueParameter.isExtensionReceiver(): Boolean {
val parentFun = parent as? IrFunction ?: return false
return parentFun.extensionReceiverParameter == this
}
private open inner class GeneratedClassHelper(protected val locId: Label<DbLocation>, protected val ids: GeneratedClassLabels) {
protected fun writeExpressionMetadataToTrapFile(id: Label<out DbExpr>, callable: Label<out DbCallable>, stmt: Label<out DbStmt>) {