Add LiveSubTypeInfo interface as a provider of sub type information

This should be populated by the enqueuer at some point to allow for
lazy loading.

Bug: 148271337
Change-Id: I7a93e7335b0f3c034d74352f44be2eccf8183cd8
diff --git a/src/main/java/com/android/tools/r8/graph/AppInfoWithSubtyping.java b/src/main/java/com/android/tools/r8/graph/AppInfoWithSubtyping.java
index 3a7e822..4c7ea07 100644
--- a/src/main/java/com/android/tools/r8/graph/AppInfoWithSubtyping.java
+++ b/src/main/java/com/android/tools/r8/graph/AppInfoWithSubtyping.java
@@ -23,7 +23,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Function;
 
-public class AppInfoWithSubtyping extends AppInfoWithClassHierarchy {
+public class AppInfoWithSubtyping extends AppInfoWithClassHierarchy implements LiveSubTypeInfo {
 
   private static final int ROOT_LEVEL = 0;
   private static final int UNKNOWN_LEVEL = -1;
@@ -32,6 +32,19 @@
   // to add to it.
   private static final Set<DexType> NO_DIRECT_SUBTYPE = ImmutableSet.of();
 
+  @Override
+  public LiveSubTypeResult getLiveSubTypes(DexType type) {
+    // TODO(b/139464956): Remove this when we start to have live type information in the enqueuer.
+    Set<DexProgramClass> programClasses = new HashSet<>();
+    for (DexType subtype : subtypes(type)) {
+      DexProgramClass subClass = definitionForProgramType(subtype);
+      if (subClass != null) {
+        programClasses.add(subClass);
+      }
+    }
+    return new LiveSubTypeResult(programClasses, null);
+  }
+
   private static class TypeInfo {
 
     private final DexType type;
diff --git a/src/main/java/com/android/tools/r8/graph/LiveSubTypeInfo.java b/src/main/java/com/android/tools/r8/graph/LiveSubTypeInfo.java
new file mode 100644
index 0000000..f812d7e
--- /dev/null
+++ b/src/main/java/com/android/tools/r8/graph/LiveSubTypeInfo.java
@@ -0,0 +1,33 @@
+// 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.graph;
+
+import java.util.Set;
+
+@FunctionalInterface
+public interface LiveSubTypeInfo {
+
+  LiveSubTypeResult getLiveSubTypes(DexType type);
+
+  class LiveSubTypeResult {
+
+    private final Set<DexProgramClass> programClasses;
+    private final Set<DexCallSite> callSites;
+
+    public LiveSubTypeResult(Set<DexProgramClass> programClasses, Set<DexCallSite> callSites) {
+      // TODO(b/149006127): Enable when we no longer rely on callSites == null.
+      this.programClasses = programClasses;
+      this.callSites = callSites;
+    }
+
+    public Set<DexProgramClass> getProgramClasses() {
+      return programClasses;
+    }
+
+    public Set<DexCallSite> getCallSites() {
+      return callSites;
+    }
+  }
+}