Reproduce b/133379765: λ group arity mismatch after unused arg removal.

Bug: 133379765
Change-Id: I4c108031133ff0fd0d4552d2853836d2c57affdd
diff --git a/src/test/java/com/android/tools/r8/kotlin/KotlinUnusedArgumentsInLambdasTest.java b/src/test/java/com/android/tools/r8/kotlin/KotlinUnusedArgumentsInLambdasTest.java
new file mode 100644
index 0000000..df7c84b
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/KotlinUnusedArgumentsInLambdasTest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.kotlin;
+
+import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
+import com.android.tools.r8.utils.InternalOptions;
+import com.android.tools.r8.utils.codeinspector.CodeInspector;
+import com.android.tools.r8.utils.codeinspector.MethodSubject;
+import com.google.common.collect.ImmutableList;
+import java.util.function.Consumer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class KotlinUnusedArgumentsInLambdasTest extends AbstractR8KotlinTestBase {
+  private Consumer<InternalOptions> optionsModifier =
+    o -> {
+      o.enableInlining = true;
+      o.enableLambdaMerging = true;
+      o.enableArgumentRemoval = true;
+      o.enableUnusedArgumentRemoval = true;
+    };
+
+  public KotlinUnusedArgumentsInLambdasTest(
+      KotlinTargetVersion targetVersion, boolean allowAccessModification) {
+    super(targetVersion, allowAccessModification);
+  }
+
+  @Ignore("b/133379765")
+  @Test
+  public void testMergingKStyleLambdasAndReprocessing() throws Exception {
+    final String mainClassName = "unused_arg_in_lambdas_kstyle.MainKt";
+    runTest("unused_arg_in_lambdas_kstyle", mainClassName, optionsModifier, app -> {
+      CodeInspector inspector = new CodeInspector(app);
+      inspector.forAllClasses(classSubject -> {
+        if (classSubject.getOriginalDescriptor().contains("$ks")) {
+          MethodSubject init = classSubject.init(ImmutableList.of("int"));
+          assertThat(init, isPresent());
+          // Arity 1 should appear.
+          assertTrue(init.iterateInstructions(i -> i.isConstNumber(1)).hasNext());
+        }
+      });
+    });
+  }
+}
diff --git a/src/test/kotlinR8TestResources/unused_arg_in_lambdas_kstyle/main.kt b/src/test/kotlinR8TestResources/unused_arg_in_lambdas_kstyle/main.kt
new file mode 100644
index 0000000..04f59b6
--- /dev/null
+++ b/src/test/kotlinR8TestResources/unused_arg_in_lambdas_kstyle/main.kt
@@ -0,0 +1,26 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package unused_arg_in_lambdas_kstyle
+
+import kotlin.jvm.internal.TypeIntrinsics
+
+private var COUNT = 11
+
+private fun next() = "${COUNT++}"
+
+fun consumeTwo(l: ((x: Any?, unused: Any?) -> Any)) : Any {
+  // This can be implicitly added by kotlinc
+  TypeIntrinsics.beforeCheckcastToFunctionOfArity(l, 2)
+  return l(next(), next())
+}
+
+private fun lambdaFactory() {
+  println(consumeTwo { x, _ -> x.toString() + "-" })
+  println(consumeTwo { x, _ -> x.toString() + "*" })
+  println(consumeTwo { x, _ -> x.toString() + "+" })
+}
+
+fun main(args: Array<String>) {
+  lambdaFactory()
+}