Change whyareyoukeeping to not report overriden members

This is compatible with proguard.

Bug: 139794417
Change-Id: I531878f12014f672cb0c5581ade279955d232714
diff --git a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
index efe918e..63a3e11 100644
--- a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
+++ b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
@@ -189,8 +189,6 @@
       } else if (rule instanceof ProguardWhyAreYouKeepingRule) {
         markClass(clazz, rule, ifRule);
         markMatchingVisibleMethods(clazz, memberKeepRules, rule, null, true, ifRule);
-        markMatchingOverriddenMethods(
-            appView.appInfo(), clazz, memberKeepRules, rule, null, true, ifRule);
         markMatchingVisibleFields(clazz, memberKeepRules, rule, null, true, ifRule);
       } else if (rule instanceof ProguardAssumeMayHaveSideEffectsRule
           || rule instanceof ProguardAssumeNoSideEffectRule
diff --git a/src/test/java/com/android/tools/r8/checkdiscarded/CheckDiscardedOverriddenMethodTest.java b/src/test/java/com/android/tools/r8/checkdiscarded/CheckDiscardedOverriddenMethodTest.java
index c6f5f11..851fff9 100644
--- a/src/test/java/com/android/tools/r8/checkdiscarded/CheckDiscardedOverriddenMethodTest.java
+++ b/src/test/java/com/android/tools/r8/checkdiscarded/CheckDiscardedOverriddenMethodTest.java
@@ -5,7 +5,6 @@
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
 
 import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.NeverClassInline;
@@ -15,12 +14,15 @@
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.utils.BooleanUtils;
 import java.util.Collection;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
+/**
+ * This test is changed based on the discussion in b/139794417 to not include overridden members
+ * which is compatible with -whyareyoukeeping.
+ */
 @RunWith(Parameterized.class)
 public class CheckDiscardedOverriddenMethodTest extends TestBase {
 
@@ -49,13 +51,9 @@
           .enableMergeAnnotations()
           .minification(minification)
           .setMinApi(parameters.getRuntime())
-          .compileWithExpectedDiagnostics(diagnostics -> {
-            diagnostics.assertInfosCount(1);
-            String message = diagnostics.getInfos().get(0).getDiagnosticMessage();
-            assertThat(message, containsString("was not discarded"));
-            assertThat(message, containsString("is invoked from"));
-          });
-      fail("Expect to get compilation failure.");
+          // Asserting that -checkdiscard is not giving any information out on an un-removed
+          // sub-type member.
+          .compileWithExpectedDiagnostics(diagnostics -> diagnostics.assertInfosCount(0));
     } catch (CompilationFailedException e) {
       String message = e.getCause().getMessage();
       assertThat(message, containsString("Discard checks failed."));
@@ -63,13 +61,11 @@
   }
 
   @Test
-  @Ignore("b/139794417")
   public void testExtends() throws Exception {
     test(TestMain1.class, Base.class);
   }
 
   @Test
-  @Ignore("b/139794417")
   public void testImplements() throws Exception {
     test(TestMain2.class, Itf.class);
   }
diff --git a/src/test/java/com/android/tools/r8/shaking/whyareyoukeeping/WhyAreYouKeepingOverriddenMethodTest.java b/src/test/java/com/android/tools/r8/shaking/whyareyoukeeping/WhyAreYouKeepingOverriddenMethodTest.java
index 84fba9e..8a28bdf 100644
--- a/src/test/java/com/android/tools/r8/shaking/whyareyoukeeping/WhyAreYouKeepingOverriddenMethodTest.java
+++ b/src/test/java/com/android/tools/r8/shaking/whyareyoukeeping/WhyAreYouKeepingOverriddenMethodTest.java
@@ -4,6 +4,7 @@
 package com.android.tools.r8.shaking.whyareyoukeeping;
 
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 import com.android.tools.r8.NeverClassInline;
@@ -14,7 +15,6 @@
 import com.android.tools.r8.references.Reference;
 import com.android.tools.r8.shaking.WhyAreYouKeepingConsumer;
 import com.android.tools.r8.utils.BooleanUtils;
-import com.android.tools.r8.utils.StringUtils;
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.nio.charset.StandardCharsets;
@@ -24,6 +24,10 @@
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
+/**
+ * This test is changed based on the discussion in b/139794417 to not include overridden members
+ * which is compatible with the proguard implementation.
+ */
 @RunWith(Parameterized.class)
 public class WhyAreYouKeepingOverriddenMethodTest extends TestBase {
   @Parameters(name = "{0} minification: {1}")
@@ -56,7 +60,8 @@
         .redirectStdOut(new PrintStream(baos))
         .compile();
     String output = new String(baos.toByteArray(), StandardCharsets.UTF_8);
-    assertThat(output, containsString(expectedMessage(main, targetClass, subClass)));
+    assertThat(output, containsString(expectedMessage(targetClass)));
+    assertThat(output, not(containsString(expectedNotContainingMessage(subClass))));
   }
 
   private void testViaConsumer(
@@ -77,22 +82,17 @@
     PrintStream printStream = new PrintStream(baos);
     graphConsumer.printWhyAreYouKeeping(
         Reference.methodFromMethod(targetClass.getMethod("gone")), printStream);
-    graphConsumer.printWhyAreYouKeeping(
-        Reference.methodFromMethod(subClass.getMethod("gone")), printStream);
     String output = new String(baos.toByteArray(), StandardCharsets.UTF_8);
-    assertThat(output, containsString(expectedMessage(main, targetClass, subClass)));
+    assertThat(output, containsString(expectedMessage(targetClass)));
+    assertThat(output, not(containsString(expectedNotContainingMessage(subClass))));
   }
 
-  private static final String MAIN_SIG = "main(java.lang.String[])";
+  private String expectedMessage(Class<?> targetClass) {
+    return "Nothing is keeping void " + targetClass.getTypeName() + ".gone()";
+  }
 
-  private String expectedMessage(Class<?> main, Class<?> targetClass, Class<?> subClass) {
-    return StringUtils.lines(
-        "Nothing is keeping void " + targetClass.getTypeName() + ".gone()",
-        "void " + subClass.getTypeName() + ".gone()",
-        "|- is invoked from:",
-        "|  void " + main.getTypeName() + "." + MAIN_SIG,
-        "|- is referenced in keep rule:",
-        "|  -keep class " + main.getTypeName() + " { public static void " + MAIN_SIG + "; }");
+  private String expectedNotContainingMessage(Class<?> subClass) {
+    return "void " + subClass.getTypeName() + ".gone()";
   }
 
   @Test