Never make static methods abstract.

Bug: 139918381
Bug: 140013075
Change-Id: I869f7726b72f66163bc55d0ef14469f0f05ffb34
diff --git a/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java b/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
index 68b1b53..8bd6e4b 100644
--- a/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
+++ b/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
@@ -593,6 +593,8 @@
     // 'final' wants this to be *not* overridden, while 'abstract' wants this to be implemented in
     // a subtype, i.e., self contradict.
     assert !accessFlags.isFinal();
+    // static abstract is an invalid access combination and we should never create that.
+    assert !accessFlags.isStatic();
     accessFlags.setAbstract();
     this.code = null;
     return this;
diff --git a/src/main/java/com/android/tools/r8/shaking/TreePruner.java b/src/main/java/com/android/tools/r8/shaking/TreePruner.java
index 3501c8a..17946f7 100644
--- a/src/main/java/com/android/tools/r8/shaking/TreePruner.java
+++ b/src/main/java/com/android/tools/r8/shaking/TreePruner.java
@@ -278,11 +278,11 @@
             && !method.accessFlags.isNative()
             && !method.accessFlags.isStrict()
             && !method.accessFlags.isSynchronized()
-            && !method.accessFlags.isPrivate();
-        // By construction, static methods cannot be reachable but non-live. For private methods
-        // this can only happen as the result of an invalid invoke. They will not actually be
-        // called at runtime but we have to keep them as non-abstract (see above) to produce the
-        // same failure mode.
+            && !method.accessFlags.isPrivate()
+            && !method.accessFlags.isStatic();
+        // Private methods and static methods can only be targeted yet non-live as the result of
+        // an invalid invoke. They will not actually be called at runtime but we have to keep them
+        // as non-abstract (see above) to produce the same failure mode.
         reachableMethods.add(
             allowAbstract
                 ? method.toAbstractMethod()
diff --git a/src/test/java/com/android/tools/r8/resolution/VirtualOverrideOfStaticMethodWithVirtualParentTest.java b/src/test/java/com/android/tools/r8/resolution/VirtualOverrideOfStaticMethodWithVirtualParentTest.java
index 57608d9..6308224 100644
--- a/src/test/java/com/android/tools/r8/resolution/VirtualOverrideOfStaticMethodWithVirtualParentTest.java
+++ b/src/test/java/com/android/tools/r8/resolution/VirtualOverrideOfStaticMethodWithVirtualParentTest.java
@@ -219,11 +219,9 @@
             .addKeepMainRule(Main.class)
             .setMinApi(parameters.getApiLevel())
             .run(parameters.getRuntime(), Main.class);
-    // TODO(b/139918381): The result of R8 contains invalid code, thus most VMs fail class loading.
-    // Some Art VMs fail too, but not in a consistent manner, so not encoding that here.
-    if (parameters.isCfRuntime()) {
-      runResult.assertFailureWithErrorThatMatches(containsString("ClassFormatError"));
-    }
+    // TODO(b/140013075): Compiling with R8 will remove Base.f, thus causing all the Art VMs to run
+    // with the "correct" yet unexpected behavior.
+    runResult.assertFailureWithErrorThatMatches(containsString(expectedRuntimeError()));
   }
 
   private boolean expectedToIncorrectlyRun(TestRuntime runtime) {