Merge "Do not remove abstract methods if they only shadow libary methods."
diff --git a/src/main/java/com/android/tools/r8/shaking/AbstractMethodRemover.java b/src/main/java/com/android/tools/r8/shaking/AbstractMethodRemover.java
index 3fd5470..fed236a 100644
--- a/src/main/java/com/android/tools/r8/shaking/AbstractMethodRemover.java
+++ b/src/main/java/com/android/tools/r8/shaking/AbstractMethodRemover.java
@@ -17,6 +17,15 @@
 import java.util.List;
 import java.util.Set;
 
+/**
+ * Removes abstract methods if they only shadow methods of the same signature in a superclass.
+ * <p>
+ * We do not consider classes from the library for this optimization, as the program might run
+ * against a different version of the library where methods are missing.
+ * <p>
+ * This optimization is beneficial mostly as it removes superfluous abstract methods that are
+ * created by the {@link TreePruner}.
+ */
 public class AbstractMethodRemover {
 
   private final AppInfoWithSubtyping appInfo;
@@ -34,7 +43,7 @@
   private void processClass(DexType type) {
     DexClass holder = appInfo.definitionFor(type);
     scope = new ScopedDexItemSet(scope);
-    if (holder != null) {
+    if (holder != null && !holder.isLibraryClass()) {
       holder.setVirtualMethods(processMethods(holder.virtualMethods()));
     }
     type.forAllExtendsSubtypes(this::processClass);
@@ -69,6 +78,7 @@
   }
 
   private static class ScopedDexItemSet {
+
     private static Equivalence<DexMethod> METHOD_EQUIVALENCE = MethodSignatureEquivalence.get();
 
     private final ScopedDexItemSet parent;