Reproduce NoSuchMethodError after single caller inlining of shared synthetic

Bug: b/416448859
Change-Id: Iad427c3b0874eb89a4477735794bcf1c12091c8e
diff --git a/src/test/java/com/android/tools/r8/partial/PartialCompilationInlineAfterSyntheticSharingTest.java b/src/test/java/com/android/tools/r8/partial/PartialCompilationInlineAfterSyntheticSharingTest.java
new file mode 100644
index 0000000..87e38fa
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/partial/PartialCompilationInlineAfterSyntheticSharingTest.java
@@ -0,0 +1,75 @@
+// Copyright (c) 2025, 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.partial;
+
+import static com.android.tools.r8.apimodel.ApiModelingTestHelper.setMockApiLevelForClass;
+
+import com.android.tools.r8.LibraryDesugaringTestConfiguration;
+import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification;
+import com.android.tools.r8.utils.AndroidApiLevel;
+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 PartialCompilationInlineAfterSyntheticSharingTest extends TestBase {
+
+  @Parameter(0)
+  public TestParameters parameters;
+
+  @Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    // Only run on runtimes where Function and Predicate are present.
+    return getTestParameters().withDexRuntimes().build();
+  }
+
+  @Test
+  public void test() throws Exception {
+    testForR8Partial(parameters.getBackend())
+        .addR8ExcludedClasses(ExcludedClass.class)
+        .addR8IncludedClasses(IncludedClass.class)
+        .addLibraryClasses(Foo.class)
+        .addLibraryFiles(ToolHelper.getMostRecentAndroidJar())
+        .apply(setMockApiLevelForClass(Foo.class, AndroidApiLevel.LATEST))
+        // Enable library desugaring so that API outlining is run lir-to-lir in R8 of R8 partial.
+        .enableCoreLibraryDesugaring(
+            LibraryDesugaringTestConfiguration.forSpecification(
+                LibraryDesugaringSpecification.JDK11.getSpecification()))
+        .setMinApi(apiLevelWithNativeMultiDexSupport())
+        .compile()
+        .addRunClasspathClasses(Foo.class)
+        .run(parameters.getRuntime(), ExcludedClass.class)
+        .assertFailureWithErrorThatThrows(NoSuchMethodError.class);
+  }
+
+  static class ExcludedClass {
+
+    public static void main(String[] args) {
+      IncludedClass.test();
+      test();
+    }
+
+    static void test() {
+      // Leads to an API outline. The API outline will be shared with the API outline from
+      // IncludedClass.test(). It is important that we don't single caller inline the shared API
+      // outline in R8 of R8 partial, since the API outline has a caller in an excluded class.
+      System.out.println(Foo.class);
+    }
+  }
+
+  static class IncludedClass {
+
+    static void test() {
+      System.out.println(Foo.class);
+    }
+  }
+
+  static class Foo {}
+}