IR: additional callable reference adapter stuff in IR

- IrFunctionReference.reflectionTarget: IrFunctionSymbol?
- add separate declaration origin for callable reference adapters
- bump IR ABI version
This commit is contained in:
Dmitry Petrov
2020-01-21 17:01:35 +03:00
parent 57bbfbbfcc
commit c540116b71
59 changed files with 420 additions and 143 deletions
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.util.patchDeclarationParents
import org.jetbrains.kotlin.ir.util.transformDeclarationsFlat
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.utils.addToStdlib.cast
class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
private val IrValueSymbol.classForImplicitThis: IrClass?
@@ -170,6 +171,13 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : FileLowe
if (!parent.isInner) return expression
val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(callee.owner)
val newReflectionTarget = expression.reflectionTarget?.let { reflectionTarget ->
if (reflectionTarget is IrConstructorSymbol) {
context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(reflectionTarget.owner)
} else {
null
}
}
val newReference = expression.run {
IrFunctionReferenceImpl(
@@ -178,6 +186,7 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : FileLowe
type,
newCallee.symbol,
typeArgumentsCount,
newReflectionTarget?.symbol,
origin
)
}
@@ -383,12 +383,14 @@ class LocalDeclarationsLowering(
val oldCallee = expression.symbol.owner
val newCallee = oldCallee.transformed ?: return expression
val newReflectionTarget = expression.reflectionTarget?.run { owner.transformed }
return IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type, // TODO functional type for transformed descriptor
newCallee.symbol,
newCallee.typeParameters.size,
newReflectionTarget?.symbol,
expression.origin
).also {
it.fillArguments2(expression, newCallee)
@@ -37,7 +37,10 @@ class ProvisionalFunctionExpressionLowering :
function,
IrFunctionReferenceImpl(
startOffset, endOffset, type,
function.symbol, 0, origin
function.symbol,
typeArgumentsCount = 0,
reflectionTarget = null,
origin = origin
)
)
)