Reproduce ClassCastException running R8

Bug: b/310939676
Change-Id: I2fdf347924eaab203e2a779bf6f1ea59e43bd9b2
diff --git a/src/test/java/com/android/tools/r8/repackage/RepackageWithoutAnyOptimizationTest.java b/src/test/java/com/android/tools/r8/repackage/RepackageWithoutAnyOptimizationTest.java
new file mode 100644
index 0000000..2dbc058
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/repackage/RepackageWithoutAnyOptimizationTest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2023, 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.repackage;
+
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import com.android.tools.r8.CompilationFailedException;
+import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class RepackageWithoutAnyOptimizationTest extends TestBase {
+
+  @Parameter() public TestParameters parameters;
+
+  @Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    return getTestParameters().withAllRuntimesAndApiLevels().build();
+  }
+
+  @Test
+  public void testR8() throws Exception {
+    Throwable t =
+        assertThrows(
+            CompilationFailedException.class,
+            () ->
+                testForR8(parameters.getBackend())
+                    .addInnerClasses(getClass())
+                    .setMinApi(parameters.getApiLevel())
+                    .addKeepMainRule(TestClass.class)
+                    .addDontOptimize()
+                    .addDontObfuscate()
+                    .addDontShrink()
+                    .addKeepRules("-repackageclasses")
+                    .compile());
+    assertTrue(t.getCause() instanceof ClassCastException);
+  }
+
+  static class TestClass {
+
+    public static void main(String[] args) {
+      System.out.println("Hello, world!");
+    }
+  }
+}