[FIR] Build resolved argument list for augmented array assignment get call
This lets us get rid of some fallback code in FIR2IR that handles unresolved argument lists. After this, we should have an invariant that all non-empty argument lists are resolved when FIR2IR runs. #KT-66124
This commit is contained in:
committed by
Space Team
parent
8443daf78d
commit
454ef4ae46
+4
-18
@@ -892,26 +892,12 @@ class CallAndReferenceGenerator(
|
|||||||
if (argumentsCount <= valueArgumentsCount) {
|
if (argumentsCount <= valueArgumentsCount) {
|
||||||
apply {
|
apply {
|
||||||
val (valueParameters, argumentMapping, substitutor) = extractArgumentsMapping(call)
|
val (valueParameters, argumentMapping, substitutor) = extractArgumentsMapping(call)
|
||||||
if (argumentMapping != null && (visitor.annotationMode || argumentMapping.isNotEmpty())) {
|
if (argumentMapping != null && (visitor.annotationMode || argumentMapping.isNotEmpty()) && valueParameters != null) {
|
||||||
if (valueParameters != null) {
|
return applyArgumentsWithReorderingIfNeeded(
|
||||||
return applyArgumentsWithReorderingIfNeeded(
|
argumentMapping, valueParameters, substitutor, contextReceiverCount, call,
|
||||||
argumentMapping, valueParameters, substitutor, contextReceiverCount, call,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Case without argument mapping (deserialized annotation)
|
|
||||||
// TODO: support argument mapping in deserialized annotations and remove me
|
|
||||||
for ((index, argument) in call.arguments.withIndex()) {
|
|
||||||
val valueParameter = when (argument) {
|
|
||||||
is FirNamedArgumentExpression -> valueParameters?.find { it.name == argument.name }
|
|
||||||
else -> null
|
|
||||||
} ?: valueParameters?.get(index)
|
|
||||||
val argumentExpression = convertArgument(argument, valueParameter, substitutor)
|
|
||||||
putValueArgument(
|
|
||||||
(valueParameters?.indexOf(valueParameter)?.takeIf { it >= 0 } ?: index) + contextReceiverCount,
|
|
||||||
argumentExpression
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
check(argumentsCount == 0) { "Non-empty unresolved argument list." }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val calleeSymbol = (this as? IrCallImpl)?.symbol
|
val calleeSymbol = (this as? IrCallImpl)?.symbol
|
||||||
|
|||||||
+16
-14
@@ -1635,23 +1635,25 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
dispatchReceiver = lhsGetCall.dispatchReceiver
|
dispatchReceiver = lhsGetCall.dispatchReceiver
|
||||||
}
|
}
|
||||||
calleeReference = lhsGetCall.calleeReference
|
calleeReference = lhsGetCall.calleeReference
|
||||||
argumentList = buildArgumentList {
|
var i = 0
|
||||||
var i = 0
|
val newMapping = (lhsGetCall.argumentList as FirResolvedArgumentList).mapping.mapKeysTo(LinkedHashMap()) { (argument) ->
|
||||||
for (argument in lhsGetCall.argumentList.arguments) {
|
if (argument is FirVarargArgumentsExpression) {
|
||||||
arguments += if (argument is FirVarargArgumentsExpression) {
|
buildVarargArgumentsExpression {
|
||||||
buildVarargArgumentsExpression {
|
val varargSize = argument.arguments.size
|
||||||
val varargSize = argument.arguments.size
|
arguments += indicesQualifiedAccessForGet.subList(i, i + varargSize)
|
||||||
arguments += indicesQualifiedAccessForGet.subList(i, i + varargSize)
|
i += varargSize
|
||||||
i += varargSize
|
source = argument.source
|
||||||
source = argument.source
|
coneTypeOrNull = argument.resolvedType
|
||||||
coneTypeOrNull = argument.resolvedType
|
coneElementTypeOrNull = argument.coneElementTypeOrNull
|
||||||
coneElementTypeOrNull = argument.coneElementTypeOrNull
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
indicesQualifiedAccessForGet[i++]
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
indicesQualifiedAccessForGet[i++]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
argumentList = buildResolvedArgumentList(
|
||||||
|
lhsGetCall.argumentList,
|
||||||
|
newMapping,
|
||||||
|
)
|
||||||
origin = FirFunctionCallOrigin.Operator
|
origin = FirFunctionCallOrigin.Operator
|
||||||
coneTypeOrNull = lhsGetCall.resolvedType
|
coneTypeOrNull = lhsGetCall.resolvedType
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user