FIR CFG: move the argument reordering hack to the expression transformer
This commit is contained in:
+2
-16
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.expressions.FirArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformInplace
|
||||
|
||||
internal class FirArgumentListImpl(
|
||||
override val source: KtSourceElement?,
|
||||
@@ -27,22 +28,7 @@ internal class FirArgumentListImpl(
|
||||
}
|
||||
|
||||
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArgumentListImpl {
|
||||
// Transform all normal arguments first and then lambda to make CFG correct. See KT-46825
|
||||
val postponedFunctionArgs = mutableListOf<Pair<Int, FirAnonymousFunctionExpression>>()
|
||||
val iterator = arguments.listIterator()
|
||||
while (iterator.hasNext()) {
|
||||
val index = iterator.nextIndex()
|
||||
val next = iterator.next() as FirPureAbstractElement
|
||||
if (next is FirAnonymousFunctionExpression) {
|
||||
postponedFunctionArgs += (index to next)
|
||||
continue
|
||||
}
|
||||
val result = next.transform<FirExpression, D>(transformer, data)
|
||||
iterator.set(result)
|
||||
}
|
||||
for ((index, lambda) in postponedFunctionArgs) {
|
||||
arguments[index] = lambda.transform(transformer, data)
|
||||
}
|
||||
arguments.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user