Handle default methods properly during tree shaking.
When tracking methods that are reachable but not yet live, we did not
handle default methods. Instead of recording them as a reachable method
that will be picked up when a subtype becomes instantiated, we just
dropped them.
This also reverts commit d9cfbd7b2d01c4895327f48cfc7c78bf811e006d, which
introduced an additional fix point. See also
https://r8-review.googlesource.com/c/r8/+/9780
Bug: 68696348
Change-Id: I05d6db4739308ee1bc869f1a6b7bbb2f493e576a
diff --git a/src/test/examplesAndroidN/shaking/SubClassOne.java b/src/test/examplesAndroidN/shaking/SubClassOne.java
new file mode 100644
index 0000000..7dfcf8d
--- /dev/null
+++ b/src/test/examplesAndroidN/shaking/SubClassOne.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2017, 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 shaking;
+
+public class SubClassOne implements InterfaceWithDefault, OtherInterfaceWithDefault {
+
+ @Override
+ public void foo() {
+ System.out.println("Method foo from SubClassOne");
+ makeSubClassTwoLive().foo();
+ asOtherInterface().bar();
+ }
+
+ private OtherInterface asOtherInterface() {
+ return new SubClassTwo();
+ }
+
+ @Override
+ public void bar() {
+ System.out.println("Method bar from SubClassOne");
+ }
+
+ private InterfaceWithDefault makeSubClassTwoLive() {
+ // Once we see this method, SubClassTwo will be live. This should also make the default method
+ // in the interface live, as SubClassTwo does not override it.
+ return new SubClassTwo();
+ }
+}