Revised "Rewrite invoke-super targeting rewritten desugared library methods."

Bug: 157806261
Change-Id: I4d2cdbdc4724a027ba553c2c2f68944f3562feb1
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java
index 901517a..98078c5 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java
@@ -307,7 +307,23 @@
                     invokeSuper.outValue(), invokeSuper.arguments()));
           } else {
             DexType dexType = maximallySpecificEmulatedInterfaceOrNull(invokedMethod);
-            if (dexType != null) {
+            if (dexType == null) {
+              if (clazz.isInterface()
+                  && appView.rewritePrefix.hasRewrittenType(clazz.type, appView)) {
+                DexEncodedMethod target =
+                    appView.appInfoForDesugaring().lookupSuperTarget(invokedMethod, code.context());
+                if (target != null && target.isDefaultMethod()) {
+                  DexClass holder = appView.definitionFor(target.holder());
+                  if (holder.isLibraryClass() && holder.isInterface()) {
+                    instructions.replaceCurrentInstruction(
+                        new InvokeStatic(
+                            defaultAsMethodOfCompanionClass(target.method, factory),
+                            invokeSuper.outValue(),
+                            invokeSuper.arguments()));
+                  }
+                }
+              }
+            } else {
               // That invoke super may not resolve since the super method may not be present
               // since it's in the emulated interface. We need to force resolution. If it resolves
               // to a library method, then it needs to be rewritten.
diff --git a/src/test/java/com/android/tools/r8/desugar/InvokeSuperToRewrittenDefaultMethodTest.java b/src/test/java/com/android/tools/r8/desugar/InvokeSuperToRewrittenDefaultMethodTest.java
index d17b37f..f63c4d9 100644
--- a/src/test/java/com/android/tools/r8/desugar/InvokeSuperToRewrittenDefaultMethodTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/InvokeSuperToRewrittenDefaultMethodTest.java
@@ -24,7 +24,6 @@
 import java.util.List;
 import java.util.function.Consumer;
 import java.util.function.IntConsumer;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -64,7 +63,6 @@
   }
 
   @Test
-  @Ignore("b/157806261")
   public void testDesugaring() throws Exception {
     assumeTrue(needsDefaultInterfaceMethodDesugaring());
     try {