Fix applying lens to already rewritten definitions

Fixes: 173974110
Change-Id: Ifa8e3dc0c627ca31755c72b07d4401287384095d
diff --git a/src/main/java/com/android/tools/r8/graph/AppView.java b/src/main/java/com/android/tools/r8/graph/AppView.java
index 806f670..ce2d937 100644
--- a/src/main/java/com/android/tools/r8/graph/AppView.java
+++ b/src/main/java/com/android/tools/r8/graph/AppView.java
@@ -9,7 +9,6 @@
 import com.android.tools.r8.graph.GraphLens.NonIdentityGraphLens;
 import com.android.tools.r8.graph.analysis.InitializedClassesInInstanceMethodsAnalysis.InitializedClassesInInstanceMethods;
 import com.android.tools.r8.graph.classmerging.HorizontallyMergedLambdaClasses;
-import com.android.tools.r8.graph.classmerging.MergedClasses;
 import com.android.tools.r8.graph.classmerging.MergedClassesCollection;
 import com.android.tools.r8.graph.classmerging.StaticallyMergedClasses;
 import com.android.tools.r8.graph.classmerging.VerticallyMergedClasses;
@@ -630,7 +629,7 @@
 
     boolean changed = appView.setGraphLens(lens);
     assert changed;
-    assert application.verifyWithLens(lens);
+    assert application.verifyWithLens(appView.appInfo().app().asDirect(), lens);
 
     // The application has already been rewritten with the given applied lens. Therefore, we
     // temporarily replace that lens with a lens that does not have any rewritings to avoid the
diff --git a/src/main/java/com/android/tools/r8/graph/DirectMappedDexApplication.java b/src/main/java/com/android/tools/r8/graph/DirectMappedDexApplication.java
index 50f4ac6..5a7d18f 100644
--- a/src/main/java/com/android/tools/r8/graph/DirectMappedDexApplication.java
+++ b/src/main/java/com/android/tools/r8/graph/DirectMappedDexApplication.java
@@ -108,8 +108,8 @@
     return "DexApplication (direct)";
   }
 
-  public boolean verifyWithLens(GraphLens lens) {
-    assert mappingIsValid(lens, allClasses.keySet());
+  public boolean verifyWithLens(DirectMappedDexApplication beforeLensApplication, GraphLens lens) {
+    assert mappingIsValid(beforeLensApplication.programClasses(), lens);
     assert verifyCodeObjectsOwners();
     return true;
   }
@@ -127,12 +127,14 @@
     return true;
   }
 
-  private boolean mappingIsValid(GraphLens graphLens, Iterable<DexType> types) {
+  private boolean mappingIsValid(
+      List<DexProgramClass> classesBeforeLensApplication, GraphLens lens) {
     // The lens might either map to a different type that is already present in the application
     // (e.g. relinking a type) or it might encode a type that was renamed, in which case the
     // original type will point to a definition that was renamed.
-    for (DexType type : types) {
-      DexType renamed = graphLens.lookupType(type);
+    for (DexProgramClass clazz : classesBeforeLensApplication) {
+      DexType type = clazz.getType();
+      DexType renamed = lens.lookupType(type);
       if (renamed.isIntType()) {
         continue;
       }
diff --git a/tools/run_on_app_dump.py b/tools/run_on_app_dump.py
index 0ceb3b0b..0d48887 100755
--- a/tools/run_on_app_dump.py
+++ b/tools/run_on_app_dump.py
@@ -319,8 +319,6 @@
     'url': 'https://github.com/chrisbanes/tivi',
     'revision': '8e2ddd8fe2d343264a66aa1ef8acbd4cc587e8ce',
     'folder': 'tivi',
-    # TODO(b/173974110): Enable recompilation.
-    'skip_recompilation': True,
   }),
   App({
     'id': 'com.keylesspalace.tusky',