Version 2.0.32

Cherry-pick: Add test and fix for not blocking super call in static methods
CL: https://r8-review.googlesource.com/48885

Bug: 149522381
Change-Id: Ib28f0c05cf50e2f1ed22d0616873acde05c79e64
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index 8a61a6c..d38eb99 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -11,7 +11,7 @@
 
   // This field is accessed from release scripts using simple pattern matching.
   // Therefore, changing this field could break our release scripts.
-  public static final String LABEL = "2.0.31";
+  public static final String LABEL = "2.0.32";
 
   private Version() {
   }
diff --git a/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java b/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
index ca31f9a..3faae09 100644
--- a/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
+++ b/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
@@ -911,10 +911,7 @@
           add(directMethods, resultingDirectMethod, MethodSignatureEquivalence.get());
           deferredRenamings.map(directMethod.method, resultingDirectMethod.method);
           deferredRenamings.recordMove(directMethod.method, resultingDirectMethod.method);
-
-          if (!directMethod.isStatic()) {
-            blockRedirectionOfSuperCalls(resultingDirectMethod.method);
-          }
+          blockRedirectionOfSuperCalls(resultingDirectMethod.method);
         }
       }
 
diff --git a/src/test/java/com/android/tools/r8/classmerging/VerticalClassMergerSuperCallInStaticTest.java b/src/test/java/com/android/tools/r8/classmerging/VerticalClassMergerSuperCallInStaticTest.java
new file mode 100644
index 0000000..8dcad81
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/classmerging/VerticalClassMergerSuperCallInStaticTest.java
@@ -0,0 +1,111 @@
+// Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.classmerging;
+
+import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
+
+import com.android.tools.r8.CompilationFailedException;
+import com.android.tools.r8.NeverInline;
+import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.utils.DescriptorUtils;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class VerticalClassMergerSuperCallInStaticTest extends TestBase {
+
+  private static final String[] EXPECTED = new String[] {"A.collect()", "Base.collect()"};
+
+  private final TestParameters parameters;
+
+  @Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    return getTestParameters().withAllRuntimesAndApiLevels().build();
+  }
+
+  public VerticalClassMergerSuperCallInStaticTest(TestParameters parameters) {
+    this.parameters = parameters;
+  }
+
+  @Test
+  public void testRuntime() throws IOException, CompilationFailedException, ExecutionException {
+    testForRuntime(parameters)
+        .addProgramClasses(Base.class, B.class, Main.class)
+        .addProgramClassFileData(getAWithRewrittenInvokeSpecialToBase())
+        .run(parameters.getRuntime(), Main.class)
+        .assertSuccessWithOutputLines(EXPECTED);
+  }
+
+  @Test
+  public void testR8() throws IOException, CompilationFailedException, ExecutionException {
+    testForR8(parameters.getBackend())
+        .addProgramClasses(Base.class, B.class, Main.class)
+        .addProgramClassFileData(getAWithRewrittenInvokeSpecialToBase())
+        .addKeepMainRule(Main.class)
+        .addKeepClassRules(Base.class, B.class)
+        .enableInliningAnnotations()
+        .setMinApi(parameters.getApiLevel())
+        .run(parameters.getRuntime(), Main.class)
+        .assertSuccessWithOutputLines(EXPECTED);
+  }
+
+  private byte[] getAWithRewrittenInvokeSpecialToBase() throws IOException {
+    return transformer(A.class)
+        .transformMethodInsnInMethod(
+            "callSuper",
+            (opcode, owner, name, descriptor, isInterface, continuation) -> {
+              continuation.apply(
+                  INVOKESPECIAL,
+                  DescriptorUtils.getBinaryNameFromJavaType(Base.class.getTypeName()),
+                  name,
+                  descriptor,
+                  false);
+            })
+        .transform();
+  }
+
+  public static class Base {
+
+    public void collect() {
+      System.out.println("Base.collect()");
+    }
+  }
+
+  public static class A extends Base {
+
+    @Override
+    @NeverInline
+    public void collect() {
+      System.out.println("A.collect()");
+    }
+
+    @NeverInline
+    public static void callSuper(A a) {
+      a.collect(); // Will be rewritten from invoke-virtual to invoke-special Base.collect();
+    }
+  }
+
+  public static class B extends A {
+
+    public void bar() {
+      collect();
+    }
+  }
+
+  public static class Main {
+
+    public static void main(String[] args) {
+      B b = new B();
+      b.bar();
+      A.callSuper(b);
+    }
+  }
+}