Proper resort variables on inlining lowered ir closures

Original problem is that lowered ir closures doesn't meet inliner expectations
 about captured variable position in inlining method.
 E.g.: Call 'foo(valueParam) { capturedParam }' to
  inline function 'foo' with declaration

      inline fun foo(valueParam: Foo, inlineParamWithCaptured: Bar.() ->) ....

 is reorganized through inlining to equivalent call foo(valueParam, capturedParam1, cp2 ...).
 But lowered closure for lambda parameter has totally different parameters order:

     fun loweredLambda$x(extensionReceiver, captured1, cp2..., valueParam1, vp2...)

 So before inlining lowered closure should be transformed to

     fun loweredLambda$x(extensionReceiver, valueParam1, vp2..., captured1, cp2..)

 #KT-28547 Fixed
This commit is contained in:
Mikhael Bogdanov
2019-01-02 14:00:43 +01:00
parent fcf8ea44b2
commit 02d9c526e2
19 changed files with 135 additions and 35 deletions
@@ -2813,6 +2813,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
runTest("compiler/testData/codegen/boxInline/simple/kt17431.kt");
}
@TestMetadata("kt28547.kt")
public void testKt28547() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/kt28547.kt");
}
@TestMetadata("kt28547_2.kt")
public void testKt28547_2() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/kt28547_2.kt");
}
@TestMetadata("params.kt")
public void testParams() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/params.kt");