[FIR2IR] Remove special handling of named arguments for vararg
FirNamedArgumentExpressions don't exist anymore during FIR2IR phase and so handling FirSpreadArgumentExpression in Fir2IrVisitor is sufficient. #KT-66124
This commit is contained in:
committed by
Space Team
parent
d16cc668cd
commit
015f257031
@@ -550,7 +550,7 @@ class Fir2IrVisitor(
|
||||
}
|
||||
|
||||
private fun FirExpression.convertToIrVarargElement(): IrVarargElement =
|
||||
if (this is FirSpreadArgumentExpression || this is FirNamedArgumentExpression && this.isSpread) {
|
||||
if (this is FirSpreadArgumentExpression) {
|
||||
IrSpreadElementImpl(
|
||||
source?.startOffset ?: UNDEFINED_OFFSET,
|
||||
source?.endOffset ?: UNDEFINED_OFFSET,
|
||||
|
||||
-18
@@ -1072,27 +1072,9 @@ class CallAndReferenceGenerator(
|
||||
}
|
||||
}
|
||||
return irArgument
|
||||
.applyAssigningArrayElementsToVarargInNamedForm(unwrappedArgument, parameter)
|
||||
.applyImplicitIntegerCoercionIfNeeded(unwrappedArgument, parameter)
|
||||
}
|
||||
|
||||
private fun IrExpression.applyAssigningArrayElementsToVarargInNamedForm(
|
||||
argument: FirExpression,
|
||||
parameter: FirValueParameter?,
|
||||
): IrExpression {
|
||||
if (this is IrVararg && parameter?.isVararg == true && argument is FirVarargArgumentsExpression && elements.size == 1) {
|
||||
val irVarargElement = elements[0]
|
||||
if (argument.arguments[0] is FirNamedArgumentExpression &&
|
||||
// IrVarargElement can be either IrSpreadElement (then nothing to do) or IrExpression
|
||||
irVarargElement is IrExpression &&
|
||||
(irVarargElement.type.isArray() || irVarargElement.type.isPrimitiveArray() || irVarargElement.type.isUnsignedArray())
|
||||
) {
|
||||
elements[0] = IrSpreadElementImpl(irVarargElement.startOffset, irVarargElement.endOffset, irVarargElement)
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
private fun IrExpression.applyImplicitIntegerCoercionIfNeeded(
|
||||
argument: FirExpression,
|
||||
parameter: FirValueParameter?,
|
||||
|
||||
Reference in New Issue
Block a user