Simplify concatElements resolution for size=0 and size=1 cases

^KT-40689 fixed
This commit is contained in:
Shagen Ogandzhanian
2021-01-08 18:38:23 +01:00
committed by TeamCityServer
parent bcfc0c21b1
commit 1dbe7d12a2
@@ -240,15 +240,18 @@ fun argumentsWithVarargAsSingleArray(
}
}
if (arraysForConcat.isNotEmpty() || concatElements.isEmpty()) {
if (arraysForConcat.isNotEmpty()) {
concatElements.add(JsArrayLiteral(arraysForConcat))
}
return concatElements.singleOrNull()
?: JsInvocation(
return when (concatElements.size) {
0 -> JsArrayLiteral()
1 -> concatElements[0]
else -> JsInvocation(
JsNameRef("concat", concatElements.first()),
concatElements.drop(1)
)
}
}
fun IrFunction.varargParameterIndex() = valueParameters.indexOfFirst { it.varargElementType != null }