JVM_IR drop 'SpecialMethodWithDefaultInfo#needsArgumentBoxing'
This commit is contained in:
+1
-2
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
data class SpecialMethodWithDefaultInfo(
|
data class SpecialMethodWithDefaultInfo(
|
||||||
val defaultValueGenerator: (IrSimpleFunction) -> IrExpression,
|
val defaultValueGenerator: (IrSimpleFunction) -> IrExpression,
|
||||||
val argumentsToCheck: Int,
|
val argumentsToCheck: Int,
|
||||||
val needsArgumentBoxing: Boolean = false,
|
|
||||||
val needsGenericSignature: Boolean = false,
|
val needsGenericSignature: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ class SpecialBridgeMethods(val context: CommonBackendContext) {
|
|||||||
makeDescription(StandardNames.FqNames.collection, "contains", 1) to
|
makeDescription(StandardNames.FqNames.collection, "contains", 1) to
|
||||||
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
||||||
makeDescription(StandardNames.FqNames.mutableCollection, "remove", 1) to
|
makeDescription(StandardNames.FqNames.mutableCollection, "remove", 1) to
|
||||||
SpecialMethodWithDefaultInfo(::constFalse, 1, needsArgumentBoxing = false),
|
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
||||||
makeDescription(StandardNames.FqNames.map, "containsKey", 1) to
|
makeDescription(StandardNames.FqNames.map, "containsKey", 1) to
|
||||||
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
||||||
makeDescription(StandardNames.FqNames.map, "containsValue", 1) to
|
makeDescription(StandardNames.FqNames.map, "containsValue", 1) to
|
||||||
|
|||||||
+14
-23
@@ -253,7 +253,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
bridgeTarget = when {
|
bridgeTarget = when {
|
||||||
irFunction.isJvmAbstract(context.state.jvmDefaultMode) -> {
|
irFunction.isJvmAbstract(context.state.jvmDefaultMode) -> {
|
||||||
irClass.declarations.remove(irFunction)
|
irClass.declarations.remove(irFunction)
|
||||||
irClass.addAbstractMethodStub(irFunction, specialBridge.methodInfo?.needsArgumentBoxing == true)
|
irClass.addAbstractMethodStub(irFunction)
|
||||||
}
|
}
|
||||||
irFunction.modality != Modality.FINAL -> {
|
irFunction.modality != Modality.FINAL -> {
|
||||||
val overriddenFromClass = irFunction.overriddenFromClass()!!
|
val overriddenFromClass = irFunction.overriddenFromClass()!!
|
||||||
@@ -367,7 +367,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
.map { it.copy(isFinal = false, isSynthetic = true, methodInfo = null) }
|
.map { it.copy(isFinal = false, isSynthetic = true, methodInfo = null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrClass.addAbstractMethodStub(irFunction: IrSimpleFunction, needsArgumentBoxing: Boolean) =
|
private fun IrClass.addAbstractMethodStub(irFunction: IrSimpleFunction) =
|
||||||
addFunction {
|
addFunction {
|
||||||
updateFrom(irFunction)
|
updateFrom(irFunction)
|
||||||
modality = Modality.ABSTRACT
|
modality = Modality.ABSTRACT
|
||||||
@@ -382,7 +382,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
copyCorrespondingPropertyFrom(irFunction)
|
copyCorrespondingPropertyFrom(irFunction)
|
||||||
dispatchReceiverParameter = thisReceiver?.copyTo(this, type = defaultType)
|
dispatchReceiverParameter = thisReceiver?.copyTo(this, type = defaultType)
|
||||||
valueParameters = irFunction.valueParameters.map { param ->
|
valueParameters = irFunction.valueParameters.map { param ->
|
||||||
param.copyTo(this, type = if (needsArgumentBoxing) param.type.makeNullable() else param.type)
|
param.copyTo(this, type = param.type)
|
||||||
}
|
}
|
||||||
overriddenSymbols = irFunction.overriddenSymbols.toList()
|
overriddenSymbols = irFunction.overriddenSymbols.toList()
|
||||||
}
|
}
|
||||||
@@ -424,12 +424,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
name = Name.identifier(specialBridge.signature.name)
|
name = Name.identifier(specialBridge.signature.name)
|
||||||
returnType = specialBridge.substitutedReturnType ?: specialBridge.overridden.returnType.eraseTypeParameters()
|
returnType = specialBridge.substitutedReturnType ?: specialBridge.overridden.returnType.eraseTypeParameters()
|
||||||
}.apply {
|
}.apply {
|
||||||
copyParametersWithErasure(
|
copyParametersWithErasure(this@addSpecialBridge, specialBridge.overridden, specialBridge.substitutedParameterTypes)
|
||||||
this@addSpecialBridge,
|
|
||||||
specialBridge.overridden,
|
|
||||||
specialBridge.methodInfo?.needsArgumentBoxing == true,
|
|
||||||
specialBridge.substitutedParameterTypes
|
|
||||||
)
|
|
||||||
|
|
||||||
body = context.createIrBuilder(symbol, startOffset, endOffset).irBlockBody {
|
body = context.createIrBuilder(symbol, startOffset, endOffset).irBlockBody {
|
||||||
specialBridge.methodInfo?.let { info ->
|
specialBridge.methodInfo?.let { info ->
|
||||||
@@ -512,32 +507,28 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
private fun IrSimpleFunction.copyParametersWithErasure(
|
private fun IrSimpleFunction.copyParametersWithErasure(
|
||||||
irClass: IrClass,
|
irClass: IrClass,
|
||||||
from: IrSimpleFunction,
|
from: IrSimpleFunction,
|
||||||
forceArgumentBoxing: Boolean = false,
|
|
||||||
substitutedParameterTypes: List<IrType>? = null
|
substitutedParameterTypes: List<IrType>? = null
|
||||||
) {
|
) {
|
||||||
// This is a workaround for a bug affecting fake overrides. Sometimes we encounter fake overrides
|
// This is a workaround for a bug affecting fake overrides. Sometimes we encounter fake overrides
|
||||||
// with dispatch receivers pointing at a superclass instead of the current class.
|
// with dispatch receivers pointing at a superclass instead of the current class.
|
||||||
dispatchReceiverParameter = irClass.thisReceiver?.copyTo(this, type = irClass.defaultType)
|
dispatchReceiverParameter = irClass.thisReceiver?.copyTo(this, type = irClass.defaultType)
|
||||||
extensionReceiverParameter = from.extensionReceiverParameter?.copyWithTypeErasure(this, forceArgumentBoxing)
|
extensionReceiverParameter = from.extensionReceiverParameter?.copyWithTypeErasure(this)
|
||||||
valueParameters = if (substitutedParameterTypes != null) {
|
valueParameters = if (substitutedParameterTypes != null) {
|
||||||
from.valueParameters.zip(substitutedParameterTypes).map { (param, type) ->
|
from.valueParameters.zip(substitutedParameterTypes).map { (param, type) ->
|
||||||
param.copyWithTypeErasure(this, forceArgumentBoxing, type)
|
param.copyWithTypeErasure(this, type)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
from.valueParameters.map { it.copyWithTypeErasure(this, forceArgumentBoxing) }
|
from.valueParameters.map { it.copyWithTypeErasure(this) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrValueParameter.copyWithTypeErasure(
|
private fun IrValueParameter.copyWithTypeErasure(target: IrSimpleFunction, substitutedType: IrType? = null): IrValueParameter =
|
||||||
target: IrSimpleFunction,
|
copyTo(
|
||||||
forceArgumentBoxing: Boolean = false,
|
target, IrDeclarationOrigin.BRIDGE,
|
||||||
substitutedType: IrType? = null
|
type = (substitutedType ?: type.eraseTypeParameters()),
|
||||||
): IrValueParameter = copyTo(
|
// Currently there are no special bridge methods with vararg parameters, so we don't track substituted vararg element types.
|
||||||
target, IrDeclarationOrigin.BRIDGE,
|
varargElementType = varargElementType?.eraseTypeParameters()
|
||||||
type = (substitutedType ?: type.eraseTypeParameters()).let { if (forceArgumentBoxing) it.makeNullable() else it },
|
)
|
||||||
// Currently there are no special bridge methods with vararg parameters, so we don't track substituted vararg element types.
|
|
||||||
varargElementType = varargElementType?.eraseTypeParameters()
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun IrBuilderWithScope.delegatingCall(
|
private fun IrBuilderWithScope.delegatingCall(
|
||||||
bridge: IrSimpleFunction,
|
bridge: IrSimpleFunction,
|
||||||
|
|||||||
Reference in New Issue
Block a user