Fix NoSuchMethodError from method merging with absent method

Bug: b/231900726
Change-Id: I67ad5cfee28f1dd69e2f5ccdcce970b159707337
diff --git a/src/main/java/com/android/tools/r8/horizontalclassmerging/IncompleteVirtuallyMergedMethodCode.java b/src/main/java/com/android/tools/r8/horizontalclassmerging/IncompleteVirtuallyMergedMethodCode.java
index 835daa4..3a10c5d 100644
--- a/src/main/java/com/android/tools/r8/horizontalclassmerging/IncompleteVirtuallyMergedMethodCode.java
+++ b/src/main/java/com/android/tools/r8/horizontalclassmerging/IncompleteVirtuallyMergedMethodCode.java
@@ -134,9 +134,13 @@
     instructions.add(fallthroughLabel);
     instructions.add(createCfFrameForSwitchCase(method, maxLocals));
 
-    DexMethod fallthroughTarget =
-        lens.getNextMethodSignature(
-            superMethod != null ? superMethod : mappedMethods.get(mappedMethods.lastIntKey()));
+    DexMethod fallthroughTarget;
+    if (superMethod == null) {
+      fallthroughTarget =
+          lens.getNextMethodSignature(mappedMethods.get(mappedMethods.lastIntKey()));
+    } else {
+      fallthroughTarget = lens.lookupInvokeSuper(superMethod, method).getReference();
+    }
     instructions.add(
         new CfInvoke(Opcodes.INVOKESPECIAL, fallthroughTarget, method.getHolder().isInterface()));
 
diff --git a/src/test/java/com/android/tools/r8/classmerging/horizontal/VirtualMethodMergingWithAbsentMethodAndSuperClassMergingTest.java b/src/test/java/com/android/tools/r8/classmerging/horizontal/VirtualMethodMergingWithAbsentMethodAndSuperClassMergingTest.java
index a7d9bf1..8ee3476 100644
--- a/src/test/java/com/android/tools/r8/classmerging/horizontal/VirtualMethodMergingWithAbsentMethodAndSuperClassMergingTest.java
+++ b/src/test/java/com/android/tools/r8/classmerging/horizontal/VirtualMethodMergingWithAbsentMethodAndSuperClassMergingTest.java
@@ -80,7 +80,7 @@
         .setMinApi(parameters.getApiLevel())
         .compile()
         .run(parameters.getRuntime(), Main.class)
-        .assertFailureWithErrorThatThrows(NoSuchMethodError.class);
+        .assertSuccessWithOutputLines("A", "B", "C", "A");
   }
 
   static class Main {