React to review comments
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ class RenderIrElementWithDescriptorsVisitor : IrElementVisitor<String, Nothing?>
|
||||
"MODULE_FRAGMENT ${declaration.descriptor}"
|
||||
|
||||
override fun visitFile(declaration: IrFile, data: Nothing?): String =
|
||||
"FILE ${declaration.name}"
|
||||
"FILE ${declaration.path}"
|
||||
|
||||
override fun visitFunction(declaration: IrFunction, data: Nothing?): String =
|
||||
"FUN ${declaration.descriptor}"
|
||||
|
||||
@@ -155,8 +155,7 @@ val IrFunctionReference.isSuspend get() = (symbol.owner as? IrSimpleFunction)?.i
|
||||
|
||||
fun IrValueParameter.copyTo(
|
||||
irFunction: IrFunction,
|
||||
shift: Int = 0,
|
||||
index: Int? = null,
|
||||
index: Int = this.index,
|
||||
startOffset: Int = this.startOffset,
|
||||
endOffset: Int = this.endOffset,
|
||||
origin: IrDeclarationOrigin = this.origin,
|
||||
@@ -164,16 +163,13 @@ fun IrValueParameter.copyTo(
|
||||
type: IrType = this.type.remapTypeParameters(this.parent as IrTypeParametersContainer, irFunction),
|
||||
varargElementType: IrType? = this.varargElementType
|
||||
): IrValueParameter {
|
||||
// You cannot specify both index and nontrivial shift.
|
||||
assert(index == null || shift == 0)
|
||||
val newIndex = index ?: (shift + this.index)
|
||||
val descriptor = WrappedValueParameterDescriptor(symbol.descriptor.annotations, symbol.descriptor.source)
|
||||
val symbol = IrValueParameterSymbolImpl(descriptor)
|
||||
val defaultValueCopy = defaultValue?.deepCopyWithVariables()
|
||||
defaultValueCopy?.patchDeclarationParents(irFunction)
|
||||
return IrValueParameterImpl(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name, newIndex, type, varargElementType, isCrossinline, isNoinline
|
||||
name, index, type, varargElementType, isCrossinline, isNoinline
|
||||
).also {
|
||||
descriptor.bind(it)
|
||||
it.parent = irFunction
|
||||
@@ -208,7 +204,7 @@ fun IrFunction.copyParameterDeclarationsFrom(from: IrFunction) {
|
||||
extensionReceiverParameter = from.extensionReceiverParameter?.copyTo(this)
|
||||
|
||||
val shift = valueParameters.size
|
||||
valueParameters += from.valueParameters.map { it.copyTo(this, shift) }
|
||||
valueParameters += from.valueParameters.map { it.copyTo(this, index = it.index + shift) }
|
||||
}
|
||||
|
||||
fun IrTypeParametersContainer.copyTypeParametersFrom(
|
||||
@@ -246,22 +242,22 @@ fun IrFunction.copyValueParametersToStatic(
|
||||
assert(target.valueParameters.isEmpty())
|
||||
|
||||
var shift = 0
|
||||
source.dispatchReceiverParameter?.apply {
|
||||
source.dispatchReceiverParameter?.let { p ->
|
||||
target.valueParameters.add(
|
||||
copyTo(
|
||||
p.copyTo(
|
||||
target,
|
||||
origin = origin,
|
||||
shift = shift++,
|
||||
origin = p.origin,
|
||||
index = p.index + shift++,
|
||||
name = Name.identifier("\$this")
|
||||
)
|
||||
)
|
||||
}
|
||||
source.extensionReceiverParameter?.apply {
|
||||
source.extensionReceiverParameter?.let { p ->
|
||||
target.valueParameters.add(
|
||||
copyTo(
|
||||
p.copyTo(
|
||||
target,
|
||||
origin = origin,
|
||||
shift = shift++,
|
||||
origin = p.origin,
|
||||
index = p.index + shift++,
|
||||
name = Name.identifier("\$receiver")
|
||||
)
|
||||
)
|
||||
@@ -271,7 +267,7 @@ fun IrFunction.copyValueParametersToStatic(
|
||||
oldValueParameter.copyTo(
|
||||
target,
|
||||
origin = origin,
|
||||
shift = shift
|
||||
index = oldValueParameter.index + shift
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+4
-4
@@ -132,8 +132,8 @@ open class DefaultArgumentStubGenerator constructor(val context: CommonBackendCo
|
||||
symbol = irFunction.symbol, descriptor = irFunction.symbol.descriptor,
|
||||
typeArgumentsCount = irFunction.typeParameters.size
|
||||
).apply {
|
||||
(0 until typeArgumentsCount).forEach { i ->
|
||||
putTypeArgument(i, newIrFunction.typeParameters[i].defaultType)
|
||||
newIrFunction.typeParameters.forEachIndexed { i, param ->
|
||||
putTypeArgument(i, param.defaultType)
|
||||
}
|
||||
dispatchReceiver = newIrFunction.dispatchReceiverParameter?.let { irGet(it) }
|
||||
|
||||
@@ -141,8 +141,8 @@ open class DefaultArgumentStubGenerator constructor(val context: CommonBackendCo
|
||||
}
|
||||
} else {
|
||||
+irReturn(irCall(irFunction).apply {
|
||||
(0 until typeArgumentsCount).forEach { i ->
|
||||
putTypeArgument(i, newIrFunction.typeParameters[i].defaultType)
|
||||
newIrFunction.typeParameters.forEachIndexed { i, param ->
|
||||
putTypeArgument(i, param.defaultType)
|
||||
}
|
||||
dispatchReceiver = newIrFunction.dispatchReceiverParameter?.let { irGet(it) }
|
||||
extensionReceiver = newIrFunction.extensionReceiverParameter?.let { irGet(it) }
|
||||
|
||||
+3
-3
@@ -255,10 +255,10 @@ class InlineClassLowering(val context: BackendContext) {
|
||||
dispatchReceiverParameter = null
|
||||
extensionReceiverParameter = function.extensionReceiverParameter?.copyTo(this)
|
||||
if (function is IrSimpleFunction) {
|
||||
valueParameters.add(function.dispatchReceiverParameter!!.copyTo(this, shift = 1))
|
||||
valueParameters += function.valueParameters.map { p -> p.copyTo(this, shift = 1) }
|
||||
valueParameters.add(function.dispatchReceiverParameter!!.let { p -> p.copyTo(this, index = p.index + 1) })
|
||||
valueParameters += function.valueParameters.map { p -> p.copyTo(this, index = p.index + 1) }
|
||||
} else {
|
||||
valueParameters += function.valueParameters.map { p -> p.copyTo(this, shift = 0) }
|
||||
valueParameters += function.valueParameters.map { p -> p.copyTo(this) }
|
||||
}
|
||||
parent = function.parent
|
||||
assert(isStaticMethodOfClass)
|
||||
|
||||
+1
-1
@@ -554,7 +554,7 @@ class LocalDeclarationsLowering(
|
||||
}
|
||||
|
||||
oldDeclaration.valueParameters.mapTo(this) { v ->
|
||||
v.copyTo(newDeclaration, capturedValues.size).also {
|
||||
v.copyTo(newDeclaration, index = v.index + capturedValues.size).also {
|
||||
newParameterToOld.putAbsentOrSame(it, v)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user