Revert "Check for missing reservation state for classes not visited"

This reverts commit cc6e5606deee7ffa7a288461ad15411c5d8e155f.

Reason for revert: Did not change the call-site - bots failing

Change-Id: Ic265ad0828f3154c8bdee471010002f6cb0e230d
diff --git a/src/main/java/com/android/tools/r8/naming/InterfaceMethodNameMinifier.java b/src/main/java/com/android/tools/r8/naming/InterfaceMethodNameMinifier.java
index a8bd96c..86dac13 100644
--- a/src/main/java/com/android/tools/r8/naming/InterfaceMethodNameMinifier.java
+++ b/src/main/java/com/android/tools/r8/naming/InterfaceMethodNameMinifier.java
@@ -104,7 +104,7 @@
     // Used for iterating the sub trees that has this node as root.
     final Set<DexType> children = new HashSet<>();
     // Collection of the frontier reservation types and the interface type itself.
-    private final Set<DexType> reservationTypes = new HashSet<>();
+    final Set<DexType> reservationTypes = new HashSet<>();
 
     InterfaceReservationState(DexClass iface) {
       this.iface = iface;
@@ -139,10 +139,6 @@
       return isReserved == null ? null : method.getName();
     }
 
-    void addReservationType(DexType type) {
-      this.reservationTypes.add(type);
-    }
-
     void reserveName(DexString reservedName, DexEncodedMethod method) {
       forAll(
           s -> {
@@ -166,7 +162,7 @@
                 }
                 return null;
               });
-      return result == null || result;
+      return result == null ? true : result;
     }
 
     void addRenaming(DexString newName, DexEncodedMethod method) {
@@ -308,7 +304,7 @@
                 }
                 return null;
               });
-      return result == null || result;
+      return result == null ? true : result;
     }
 
     void addRenaming(DexString newName, MethodNameMinifier.State minifierState) {
@@ -402,7 +398,7 @@
       assert iface.isInterface();
       minifierState.allocateReservationStateAndReserve(iface.type, iface.type);
       InterfaceReservationState iFaceState = new InterfaceReservationState(iface);
-      iFaceState.addReservationType(iface.type);
+      iFaceState.reservationTypes.add(iface.type);
       interfaceStateMap.put(iface.type, iFaceState);
     }
   }
@@ -648,12 +644,8 @@
                   InterfaceReservationState iState = interfaceStateMap.get(directlyImplemented);
                   if (iState != null) {
                     DexType frontierType = minifierState.getFrontier(clazz.type);
-                    iState.addReservationType(frontierType);
-                    // The reservation state should already be added, but if a class is extending
-                    // an interface, we will not visit the class during the sub-type traversel
-                    if (minifierState.getReservationState(clazz.type) == null) {
-                      minifierState.allocateReservationStateAndReserve(clazz.type, frontierType);
-                    }
+                    assert minifierState.getReservationState(frontierType) != null;
+                    iState.reservationTypes.add(frontierType);
                   }
                 }
               }
diff --git a/src/main/java/com/android/tools/r8/naming/Minifier.java b/src/main/java/com/android/tools/r8/naming/Minifier.java
index 4bc638a..9893fb7 100644
--- a/src/main/java/com/android/tools/r8/naming/Minifier.java
+++ b/src/main/java/com/android/tools/r8/naming/Minifier.java
@@ -26,7 +26,6 @@
 import com.android.tools.r8.utils.SymbolGenerationUtils;
 import com.android.tools.r8.utils.SymbolGenerationUtils.MixedCasing;
 import com.android.tools.r8.utils.Timing;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -48,7 +47,7 @@
     assert appView.options().isMinifying();
     SubtypingInfo subtypingInfo = appView.appInfo().computeSubtypingInfo();
     timing.begin("ComputeInterfaces");
-    Set<DexClass> interfaces = new TreeSet<>(Comparator.comparing(a -> a.type));
+    Set<DexClass> interfaces = new TreeSet<>((a, b) -> a.type.compareTo(b.type));
     interfaces.addAll(appView.appInfo().computeReachableInterfaces());
     timing.end();
     timing.begin("MinifyClasses");
diff --git a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
index 32cd619..8e65d5c 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -649,33 +649,6 @@
     }
   }
 
-  private void warnIfClassExtendsInterfaceOrImplementsClass(DexProgramClass clazz) {
-    if (clazz.superType != null) {
-      DexClass superClass = definitionFor(clazz.superType);
-      if (superClass != null && superClass.isInterface()) {
-        options.reporter.warning(
-            new StringDiagnostic(
-                "Class "
-                    + clazz.toSourceString()
-                    + " extends "
-                    + superClass.toSourceString()
-                    + " which is an interface"));
-      }
-    }
-    for (DexType iface : clazz.interfaces.values) {
-      DexClass ifaceClass = definitionFor(iface);
-      if (ifaceClass != null && !ifaceClass.isInterface()) {
-        options.reporter.warning(
-            new StringDiagnostic(
-                "Class "
-                    + clazz.toSourceString()
-                    + " implements "
-                    + ifaceClass.toSourceString()
-                    + " which is not an interface"));
-      }
-    }
-  }
-
   private void enqueueRootItems(Map<DexReference, Set<ProguardKeepRuleBase>> items) {
     items.entrySet().forEach(this::enqueueRootItem);
   }
@@ -1708,9 +1681,6 @@
       markTypeAsLive(holder.superType, reason);
     }
 
-    // Warn if the class extends an interface or implements a class
-    warnIfLibraryExtendsInterfaceOrImplementsClass(holder);
-
     // If this is an interface that has just become live, then report previously seen but unreported
     // implemented-by edges.
     transitionUnusedInterfaceToLive(holder);
diff --git a/src/test/java/com/android/tools/r8/ExternalR8TestCompileResult.java b/src/test/java/com/android/tools/r8/ExternalR8TestCompileResult.java
index a7c0baf..ea6b2f7 100644
--- a/src/test/java/com/android/tools/r8/ExternalR8TestCompileResult.java
+++ b/src/test/java/com/android/tools/r8/ExternalR8TestCompileResult.java
@@ -5,6 +5,7 @@
 package com.android.tools.r8;
 
 import com.android.tools.r8.ToolHelper.ProcessResult;
+import com.android.tools.r8.errors.Unimplemented;
 import com.android.tools.r8.utils.AndroidApp;
 import com.android.tools.r8.utils.codeinspector.CodeInspector;
 import java.io.IOException;
@@ -40,6 +41,14 @@
     return proguardMap;
   }
 
+  public String stdout() {
+    return processResult.stdout;
+  }
+
+  public String stderr() {
+    return processResult.stdout;
+  }
+
   @Override
   public ExternalR8TestCompileResult self() {
     return this;
@@ -52,12 +61,12 @@
 
   @Override
   public String getStdout() {
-    return processResult.stdout;
+    throw new Unimplemented("Unexpected attempt to access stdout from external R8");
   }
 
   @Override
   public String getStderr() {
-    return processResult.stderr;
+    throw new Unimplemented("Unexpected attempt to access stderr from external R8");
   }
 
   @Override
diff --git a/src/test/java/com/android/tools/r8/cf/bootstrap/BootstrapCurrentEqualityTest.java b/src/test/java/com/android/tools/r8/cf/bootstrap/BootstrapCurrentEqualityTest.java
index f2660ef..070d6c8 100644
--- a/src/test/java/com/android/tools/r8/cf/bootstrap/BootstrapCurrentEqualityTest.java
+++ b/src/test/java/com/android/tools/r8/cf/bootstrap/BootstrapCurrentEqualityTest.java
@@ -257,8 +257,8 @@
             .setMode(mode)
             .compile();
     // Check that the process outputs (exit code, stdout, stderr) are the same.
-    assertEquals(result.getStdout(), runR8R8.getStdout());
-    assertEquals(result.getStderr(), runR8R8.getStderr());
+    assertEquals(result.stdout(), runR8R8.stdout());
+    assertEquals(result.stderr(), runR8R8.stderr());
     // Check that the output jars are the same.
     assertProgramsEqual(result.outputJar(), runR8R8.outputJar());
   }
diff --git a/src/test/java/com/android/tools/r8/naming/b173184123/ClassExtendsInterfaceNamingTest.java b/src/test/java/com/android/tools/r8/naming/b173184123/ClassExtendsInterfaceNamingTest.java
index fccc7b2..daf872a 100644
--- a/src/test/java/com/android/tools/r8/naming/b173184123/ClassExtendsInterfaceNamingTest.java
+++ b/src/test/java/com/android/tools/r8/naming/b173184123/ClassExtendsInterfaceNamingTest.java
@@ -5,6 +5,8 @@
 package com.android.tools.r8.naming.b173184123;
 
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertThrows;
 
 import com.android.tools.r8.NeverClassInline;
 import com.android.tools.r8.NeverInline;
@@ -50,28 +52,28 @@
                 .setSuper(DescriptorUtils.javaTypeToDescriptor(Interface.class.getTypeName()))
                 .transform())
         .build();
-    testForExternalR8(
-            parameters.getBackend(),
-            parameters.isCfRuntime() ? parameters.getRuntime() : TestRuntime.getCheckedInJdk11())
-        .addProgramFiles(classFiles)
-        .enableAssertions(false)
-        .useR8WithRelocatedDeps()
-        .setMinApi(parameters.getApiLevel())
-        .addKeepMainRule(Main.class)
-        .addKeepClassAndMembersRules(Interface.class)
-        .addKeepRules("-neverclassinline @com.android.tools.r8.NeverClassInline class *")
-        .addKeepRules("-neverinline class * { @**.NeverInline *; }")
-        .allowTestProguardOptions(true)
-        .compile()
-        .assertStderrThatMatches(
-            containsString(
-                "Class "
-                    + ConcreteClass.class.getTypeName()
-                    + " extends "
-                    + Interface.class.getTypeName()
-                    + " which is an interface"))
-        .run(parameters.getRuntime(), Main.class)
-        .assertFailureWithErrorThatThrows(IncompatibleClassChangeError.class);
+    // TODO(b/173184123): Should not result in an error.
+    AssertionError assertionError =
+        assertThrows(
+            AssertionError.class,
+            () -> {
+              testForExternalR8(
+                      parameters.getBackend(),
+                      parameters.isCfRuntime()
+                          ? parameters.getRuntime()
+                          : TestRuntime.getCheckedInJdk11())
+                  .addProgramFiles(classFiles)
+                  .enableAssertions(false)
+                  .setMinApi(parameters.getApiLevel())
+                  .addKeepMainRule(Main.class)
+                  .addKeepClassAndMembersRules(Interface.class)
+                  .addKeepRules("-neverclassinline @com.android.tools.r8.NeverClassInline class *")
+                  .addKeepRules("-neverinline class * { @**.NeverInline *; }")
+                  .allowTestProguardOptions(true)
+                  .compile();
+            });
+    assertThat(
+        assertionError.getMessage(), containsString("Error: java.lang.NullPointerException"));
   }
 
   public interface Interface {