Revert "Remove uses of definitionFor(DexMethod) from desugaring"

This reverts commit a317737830ffd2815e33637f334b11950b6d4638.

Reason for revert: Bot failures

Change-Id: Ia2f825f20208ed5948c711a6dbfd761ea8e882de
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 74a31bf..670344c 100644
--- a/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
+++ b/src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
@@ -258,10 +258,6 @@
     return getReference().name;
   }
 
-  public DexProto getProto() {
-    return getReference().proto;
-  }
-
   public DexMethod getReference() {
     return method;
   }
diff --git a/src/main/java/com/android/tools/r8/graph/DexItemFactory.java b/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
index e0beea9..d61746d 100644
--- a/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
+++ b/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
@@ -1887,10 +1887,6 @@
     return createProto(proto.returnType, parameterTypes);
   }
 
-  public DexProto prependHolderToProto(DexMethod method) {
-    return prependTypeToProto(method.holder, method.proto);
-  }
-
   public DexProto prependTypeToProto(DexType extraFirstType, DexProto initialProto) {
     DexType[] parameterTypes = new DexType[initialProto.parameters.size() + 1];
     parameterTypes[0] = extraFirstType;
diff --git a/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java b/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java
index 57d52df..50cec6e 100644
--- a/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java
+++ b/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java
@@ -12,7 +12,6 @@
 import com.android.tools.r8.graph.DexField;
 import com.android.tools.r8.graph.DexString;
 import com.android.tools.r8.graph.DexType;
-import com.android.tools.r8.graph.ProgramMethod;
 import com.android.tools.r8.ir.analysis.type.TypeAnalysis;
 import com.android.tools.r8.ir.analysis.type.TypeElement;
 import com.android.tools.r8.ir.code.Phi.RegisterReadType;
@@ -545,14 +544,12 @@
       Set<BasicBlock> blocksToRemove,
       DexType downcast) {
     assert blocksToRemove != null;
-    ProgramMethod callerContext = code.context();
-    ProgramMethod calleeContext = inlinee.context();
-    if (callerContext.getHolder() != calleeContext.getHolder()
-        && calleeContext.getDefinition().isOnlyInlinedIntoNestMembers()) {
+    DexType codeHolder = code.method().holder();
+    DexType inlineeHolder = inlinee.method().holder();
+    if (codeHolder != inlineeHolder && inlinee.method().isOnlyInlinedIntoNestMembers()) {
       // Should rewrite private calls to virtual calls.
-      assert NestUtils.sameNest(
-          callerContext.getHolderType(), calleeContext.getHolderType(), appView);
-      NestUtils.rewriteNestCallsForInlining(inlinee, callerContext, appView);
+      assert NestUtils.sameNest(codeHolder, inlineeHolder, appView);
+      NestUtils.rewriteNestCallsForInlining(inlinee, codeHolder, appView);
     }
     boolean inlineeCanThrow = canThrow(inlinee);
     // Split the block with the invocation into three blocks, where the first block contains all
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/ClassProcessor.java b/src/main/java/com/android/tools/r8/ir/desugar/ClassProcessor.java
index 3971c88..4737d39 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/ClassProcessor.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/ClassProcessor.java
@@ -337,7 +337,8 @@
     if (method.isFinal()) {
       return false;
     }
-    return appView.options().desugaredLibraryConfiguration.retargetMethod(method, appView) != null;
+    return appView.options().desugaredLibraryConfiguration.retargetMethod(method.method, appView)
+        != null;
   }
 
   private boolean dontRewrite(DexClass clazz, DexEncodedMethod method) {
@@ -395,7 +396,7 @@
     DexMethod forwardMethod =
         targetHolder.isInterface()
             ? rewriter.defaultAsMethodOfCompanionClass(method)
-            : appView.options().desugaredLibraryConfiguration.retargetMethod(target, appView);
+            : appView.options().desugaredLibraryConfiguration.retargetMethod(method, appView);
     DexEncodedMethod desugaringForwardingMethod =
         DexEncodedMethod.createDesugaringForwardingMethod(
             target, clazz, forwardMethod, dexItemFactory);
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/D8NestBasedAccessDesugaring.java b/src/main/java/com/android/tools/r8/ir/desugar/D8NestBasedAccessDesugaring.java
index bd468b0..ba49fc0 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/D8NestBasedAccessDesugaring.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/D8NestBasedAccessDesugaring.java
@@ -65,18 +65,12 @@
         Instruction instruction = instructions.next();
         if (instruction.isInvokeMethod()) {
           InvokeMethod invokeMethod = instruction.asInvokeMethod();
-          DexMethod invokedMethod = invokeMethod.getInvokedMethod();
-          if (!invokedMethod.holder.isClassType()) {
-            continue;
-          }
-          // Since we only need to desugar accesses to private methods, and all accesses to private
-          // methods must be accessing the private method directly on its holder, we can lookup the
-          // method on the holder instead of resolving the method.
-          DexClass holder = appView.definitionForHolder(invokedMethod);
-          DexEncodedMethod definition = invokedMethod.lookupOnClass(holder);
-          if (definition != null && invokeRequiresRewriting(definition, method)) {
-            DexMethod bridge = ensureInvokeBridge(definition);
-            if (definition.isInstanceInitializer()) {
+          DexMethod methodCalled = invokeMethod.getInvokedMethod();
+          DexEncodedMethod encodedMethodCalled =
+              methodCalled.holder.isClassType() ? appView.definitionFor(methodCalled) : null;
+          if (encodedMethodCalled != null && invokeRequiresRewriting(encodedMethodCalled, method)) {
+            DexMethod bridge = ensureInvokeBridge(encodedMethodCalled);
+            if (encodedMethodCalled.isInstanceInitializer()) {
               instructions.previous();
               Value extraNullValue =
                   instructions.insertConstNullInstruction(code, appView.options());
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryConfiguration.java b/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryConfiguration.java
index a7d5252..1590484 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryConfiguration.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryConfiguration.java
@@ -6,7 +6,6 @@
 
 import com.android.tools.r8.errors.CompilationError;
 import com.android.tools.r8.graph.AppView;
-import com.android.tools.r8.graph.DexEncodedMethod;
 import com.android.tools.r8.graph.DexItemFactory;
 import com.android.tools.r8.graph.DexMethod;
 import com.android.tools.r8.graph.DexString;
@@ -133,15 +132,15 @@
   }
 
   // If the method is retargeted, answers the retargeted method, else null.
-  public DexMethod retargetMethod(DexEncodedMethod method, AppView<?> appView) {
-    Map<DexType, DexType> typeMap = retargetCoreLibMember.get(method.getName());
-    if (typeMap != null && typeMap.containsKey(method.getHolderType())) {
+  public DexMethod retargetMethod(DexMethod method, AppView<?> appView) {
+    Map<DexType, DexType> typeMap = retargetCoreLibMember.get(method.name);
+    if (typeMap != null && typeMap.containsKey(method.holder)) {
       return appView
           .dexItemFactory()
           .createMethod(
-              typeMap.get(method.getHolderType()),
-              appView.dexItemFactory().prependHolderToProto(method.getReference()),
-              method.getName());
+              typeMap.get(method.holder),
+              appView.dexItemFactory().prependTypeToProto(method.holder, method.proto),
+              method.name);
     }
     return null;
   }
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryRetargeter.java b/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryRetargeter.java
index cfb48f2..53ff67e 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryRetargeter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryRetargeter.java
@@ -55,7 +55,7 @@
   // d8 needs to force resolution of given methods to see if the invoke needs to be rewritten.
   private final Map<DexString, List<DexMethod>> virtualRewrites = new IdentityHashMap<>();
   // Non final virtual library methods requiring generation of emulated dispatch.
-  private final Set<DexEncodedMethod> emulatedDispatchMethods = Sets.newIdentityHashSet();
+  private final Set<DexMethod> emulatedDispatchMethods = Sets.newHashSet();
 
   public DesugaredLibraryRetargeter(AppView<?> appView) {
     this.appView = appView;
@@ -139,7 +139,7 @@
               appView
                   .options()
                   .desugaredLibraryConfiguration
-                  .retargetMethod(dexEncodedMethod, appView);
+                  .retargetMethod(dexEncodedMethod.method, appView);
           if (retargetMethod != null) {
             iterator.replaceCurrentInstruction(
                 new InvokeStatic(retargetMethod, invoke.outValue(), invoke.arguments()));
@@ -197,8 +197,8 @@
                 } else if (!encodedMethod.isFinal()) {
                   // Virtual rewrites require emulated dispatch for inheritance.
                   // The call is rewritten to the dispatch holder class instead.
-                  handleEmulateDispatch(appView, encodedMethod);
-                  newHolder = dispatchHolderTypeFor(encodedMethod);
+                  handleEmulateDispatch(appView, encodedMethod.method);
+                  newHolder = dispatchHolderTypeFor(encodedMethod.method);
                 }
               }
               DexProto proto = encodedMethod.method.proto;
@@ -213,7 +213,8 @@
 
     private DexMethod computeRetargetMethod(DexMethod method, boolean isStatic, DexType newHolder) {
       DexItemFactory factory = appView.dexItemFactory();
-      DexProto newProto = isStatic ? method.proto : factory.prependHolderToProto(method);
+      DexProto newProto =
+          isStatic ? method.proto : factory.prependTypeToProto(method.holder, method.proto);
       return factory.createMethod(newHolder, newProto, method.name);
     }
 
@@ -229,7 +230,7 @@
       return found;
     }
 
-    private void handleEmulateDispatch(AppView<?> appView, DexEncodedMethod method) {
+    private void handleEmulateDispatch(AppView<?> appView, DexMethod method) {
       emulatedDispatchMethods.add(method);
       if (!appView.options().isDesugaredLibraryCompilation()) {
         // Add rewrite rules so keeps rules are correctly generated in the program.
@@ -265,10 +266,10 @@
     private void addInterfacesAndForwardingMethods(
         ExecutorService executorService, IRConverter converter) throws ExecutionException {
       assert !appView.options().isDesugaredLibraryCompilation();
-      Map<DexType, List<DexEncodedMethod>> map = Maps.newIdentityHashMap();
-      for (DexEncodedMethod emulatedDispatchMethod : emulatedDispatchMethods) {
-        map.putIfAbsent(emulatedDispatchMethod.getHolderType(), new ArrayList<>(1));
-        map.get(emulatedDispatchMethod.getHolderType()).add(emulatedDispatchMethod);
+      Map<DexType, List<DexMethod>> map = Maps.newIdentityHashMap();
+      for (DexMethod emulatedDispatchMethod : emulatedDispatchMethods) {
+        map.putIfAbsent(emulatedDispatchMethod.holder, new ArrayList<>(1));
+        map.get(emulatedDispatchMethod.holder).add(emulatedDispatchMethod);
       }
       SortedProgramMethodSet addedMethods = SortedProgramMethodSet.create();
       for (DexProgramClass clazz : appView.appInfo().classes()) {
@@ -294,8 +295,7 @@
       converter.processMethodsConcurrently(addedMethods, executorService);
     }
 
-    private boolean inherit(
-        DexLibraryClass clazz, DexType typeToInherit, Set<DexEncodedMethod> retarget) {
+    private boolean inherit(DexLibraryClass clazz, DexType typeToInherit, Set<DexMethod> retarget) {
       DexLibraryClass current = clazz;
       while (current.type != appView.dexItemFactory().objectType) {
         if (current.type == typeToInherit) {
@@ -316,35 +316,36 @@
 
     private void addInterfacesAndForwardingMethods(
         DexProgramClass clazz,
-        List<DexEncodedMethod> methods,
+        List<DexMethod> methods,
         Consumer<DexEncodedMethod> newForwardingMethodsConsumer) {
       // DesugaredLibraryRetargeter emulate dispatch: insertion of a marker interface & forwarding
       // methods.
       // We cannot use the ClassProcessor since this applies up to 26, while the ClassProcessor
       // applies up to 24.
-      for (DexEncodedMethod method : methods) {
+      for (DexMethod dexMethod : methods) {
         DexType[] newInterfaces =
             Arrays.copyOf(clazz.interfaces.values, clazz.interfaces.size() + 1);
-        newInterfaces[newInterfaces.length - 1] = dispatchInterfaceTypeFor(method);
+        newInterfaces[newInterfaces.length - 1] = dispatchInterfaceTypeFor(dexMethod);
         clazz.interfaces = new DexTypeList(newInterfaces);
-        if (clazz.lookupVirtualMethod(method.getReference()) == null) {
-          DexEncodedMethod newMethod = createForwardingMethod(method, clazz);
+        DexEncodedMethod dexEncodedMethod = clazz.lookupVirtualMethod(dexMethod);
+        if (dexEncodedMethod == null) {
+          DexEncodedMethod newMethod = createForwardingMethod(dexMethod, clazz);
           clazz.addVirtualMethod(newMethod);
           newForwardingMethodsConsumer.accept(newMethod);
         }
       }
     }
 
-    private DexEncodedMethod createForwardingMethod(DexEncodedMethod target, DexClass clazz) {
+    private DexEncodedMethod createForwardingMethod(DexMethod target, DexClass clazz) {
       // NOTE: Never add a forwarding method to methods of classes unknown or coming from
       // android.jar
       // even if this results in invalid code, these classes are never desugared.
       // In desugared library, emulated interface methods can be overridden by retarget lib members.
       DexMethod forwardMethod =
           appView.options().desugaredLibraryConfiguration.retargetMethod(target, appView);
-      assert forwardMethod != null && forwardMethod != target.getReference();
+      assert forwardMethod != null && forwardMethod != target;
       return DexEncodedMethod.createDesugaringForwardingMethod(
-          target, clazz, forwardMethod, appView.dexItemFactory());
+          appView.definitionFor(target), clazz, forwardMethod, appView.dexItemFactory());
     }
 
     private void synthesizeEmulatedDispatchMethods(DexApplication.Builder<?> builder) {
@@ -360,7 +361,7 @@
                   | Constants.ACC_INTERFACE);
       ClassAccessFlags holderAccessFlags =
           ClassAccessFlags.fromSharedAccessFlags(Constants.ACC_PUBLIC | Constants.ACC_SYNTHETIC);
-      for (DexEncodedMethod emulatedDispatchMethod : emulatedDispatchMethods) {
+      for (DexMethod emulatedDispatchMethod : emulatedDispatchMethods) {
         // Dispatch interface.
         DexType interfaceType = dispatchInterfaceTypeFor(emulatedDispatchMethod);
         DexEncodedMethod itfMethod =
@@ -389,7 +390,7 @@
     }
 
     private DexEncodedMethod generateInterfaceDispatchMethod(
-        DexEncodedMethod emulatedDispatchMethod, DexType interfaceType) {
+        DexMethod emulatedDispatchMethod, DexType interfaceType) {
       MethodAccessFlags flags =
           MethodAccessFlags.fromSharedAccessFlags(
               Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT | Constants.ACC_SYNTHETIC, false);
@@ -397,15 +398,13 @@
           appView
               .dexItemFactory()
               .createMethod(
-                  interfaceType,
-                  emulatedDispatchMethod.getProto(),
-                  emulatedDispatchMethod.getName());
+                  interfaceType, emulatedDispatchMethod.proto, emulatedDispatchMethod.name);
       return new DexEncodedMethod(
           newMethod, flags, DexAnnotationSet.empty(), ParameterAnnotationsList.empty(), null, true);
     }
 
     private DexEncodedMethod generateHolderDispatchMethod(
-        DexEncodedMethod emulatedDispatchMethod, DexType dispatchHolder, DexMethod itfMethod) {
+        DexMethod emulatedDispatchMethod, DexType dispatchHolder, DexMethod itfMethod) {
       // The method should look like:
       // static foo(rcvr, arg0, arg1) {
       //    if (rcvr instanceof interfaceType) {
@@ -424,9 +423,9 @@
       DexMethod newMethod =
           appView
               .dexItemFactory()
-              .createMethod(dispatchHolder, desugarMethod.proto, emulatedDispatchMethod.getName());
+              .createMethod(dispatchHolder, desugarMethod.proto, emulatedDispatchMethod.name);
       return DexEncodedMethod.toEmulateDispatchLibraryMethod(
-          emulatedDispatchMethod.getHolderType(),
+          emulatedDispatchMethod.holder,
           newMethod,
           desugarMethod,
           itfMethod,
@@ -436,7 +435,7 @@
   }
 
   private void reportInvalidLibrarySupertype(
-      DexLibraryClass libraryClass, Set<DexEncodedMethod> retarget) {
+      DexLibraryClass libraryClass, Set<DexMethod> retarget) {
     DexClass dexClass = appView.definitionFor(libraryClass.superType);
     String message;
     if (dexClass == null) {
@@ -457,15 +456,15 @@
             retarget);
   }
 
-  private DexType dispatchInterfaceTypeFor(DexEncodedMethod method) {
+  private DexType dispatchInterfaceTypeFor(DexMethod method) {
     return dispatchTypeFor(method, "dispatchInterface");
   }
 
-  private DexType dispatchHolderTypeFor(DexEncodedMethod method) {
+  private DexType dispatchHolderTypeFor(DexMethod method) {
     return dispatchTypeFor(method, "dispatchHolder");
   }
 
-  private DexType dispatchTypeFor(DexEncodedMethod method, String suffix) {
+  private DexType dispatchTypeFor(DexMethod method, String suffix) {
     String descriptor =
         "L"
             + appView
@@ -474,9 +473,9 @@
                 .getSynthesizedLibraryClassesPackagePrefix()
             + DESUGAR_LIB_RETARGET_CLASS_NAME_PREFIX
             + '$'
-            + method.getHolderType().getName()
+            + method.holder.getName()
             + '$'
-            + method.getName()
+            + method.name
             + '$'
             + suffix
             + ';';
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java
index ae5d906..901517a 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/InterfaceMethodRewriter.java
@@ -324,7 +324,7 @@
                   // retarget or if it just calls a companion class method and rewrite.
                   DexMethod retargetMethod =
                       options.desugaredLibraryConfiguration.retargetMethod(
-                          dexEncodedMethod, appView);
+                          dexEncodedMethod.method, appView);
                   if (retargetMethod == null) {
                     DexMethod originalCompanionMethod =
                         instanceAsMethodOfCompanionClass(
@@ -357,7 +357,7 @@
             continue;
           }
 
-          DexClass clazz = appInfo.definitionForHolder(method);
+          DexClass clazz = appInfo.definitionFor(method.holder);
           if (clazz == null) {
             // Report missing class since we don't know if it is an interface.
             warnMissingType(encodedMethod.method, method.holder);
@@ -367,7 +367,7 @@
                   "defined in library class " + clazz.toSourceString(),
                   getMethodOrigin(encodedMethod.method));
             }
-            DexEncodedMethod directTarget = clazz.lookupDirectMethod(method);
+            DexEncodedMethod directTarget = appView.definitionFor(method);
             if (directTarget != null) {
               // This can be a private instance method call. Note that the referenced
               // method is expected to be in the current class since it is private, but desugaring
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/NestBasedAccessDesugaring.java b/src/main/java/com/android/tools/r8/ir/desugar/NestBasedAccessDesugaring.java
index 58730b9..2586141 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/NestBasedAccessDesugaring.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/NestBasedAccessDesugaring.java
@@ -86,9 +86,8 @@
 
   private DexEncodedMethod lookupOnHolder(
       DexMethod method, DexClassAndMethod context, Invoke.Type invokeType) {
-    DexMethod rewritten =
-        appView.graphLense().lookupMethod(method, context.getReference(), invokeType).getMethod();
-    return rewritten.lookupOnClass(appView.definitionForHolder(rewritten));
+    return appView.definitionFor(
+        appView.graphLense().lookupMethod(method, context.getReference(), invokeType).getMethod());
   }
 
   private DexEncodedField lookupOnHolder(DexField field) {
@@ -236,7 +235,7 @@
     DexProto proto =
         encodedMethod.accessFlags.isStatic()
             ? method.proto
-            : appView.dexItemFactory().prependHolderToProto(method);
+            : appView.dexItemFactory().prependTypeToProto(method.holder, method.proto);
     return appView
         .dexItemFactory()
         .createMethod(method.holder, proto, computeMethodBridgeName(encodedMethod));
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/NestUtils.java b/src/main/java/com/android/tools/r8/ir/optimize/NestUtils.java
index 5ee91d0..9db947a 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/NestUtils.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/NestUtils.java
@@ -10,7 +10,6 @@
 import com.android.tools.r8.graph.DexEncodedMethod;
 import com.android.tools.r8.graph.DexMethod;
 import com.android.tools.r8.graph.DexType;
-import com.android.tools.r8.graph.ProgramMethod;
 import com.android.tools.r8.ir.code.IRCode;
 import com.android.tools.r8.ir.code.Instruction;
 import com.android.tools.r8.ir.code.InstructionListIterator;
@@ -42,45 +41,42 @@
   }
 
   public static void rewriteNestCallsForInlining(
-      IRCode code, ProgramMethod callerContext, AppView<?> appView) {
+      IRCode code, DexType callerHolder, AppView<?> appView) {
     // This method is called when inlining code into the nest member callerHolder.
     InstructionListIterator iterator = code.instructionListIterator();
-    assert code.context().getHolder() != callerContext.getHolder();
+    DexClass callerHolderClass = appView.definitionFor(callerHolder);
+    assert callerHolderClass != null;
+    assert code.method().holder() != callerHolder;
     while (iterator.hasNext()) {
       Instruction instruction = iterator.next();
       if (instruction.isInvokeDirect()) {
         InvokeDirect invoke = instruction.asInvokeDirect();
         DexMethod method = invoke.getInvokedMethod();
-        DexClass holder = appView.definitionForHolder(method);
-        DexEncodedMethod encodedMethod = method.lookupOnClass(holder);
+        DexEncodedMethod encodedMethod = appView.definitionFor(method);
         if (encodedMethod != null && !encodedMethod.isInstanceInitializer()) {
           assert encodedMethod.isPrivateMethod();
           // Call to private method which has now to be interface/virtual
           // (Now call to nest member private method).
           if (invoke.getInterfaceBit()) {
             iterator.replaceCurrentInstruction(
-                new InvokeInterface(method, invoke.outValue(), invoke.arguments()));
+                new InvokeInterface(method, invoke.outValue(), invoke.inValues()));
           } else {
             iterator.replaceCurrentInstruction(
-                new InvokeVirtual(method, invoke.outValue(), invoke.arguments()));
+                new InvokeVirtual(method, invoke.outValue(), invoke.inValues()));
           }
         }
       } else if (instruction.isInvokeInterface() || instruction.isInvokeVirtual()) {
         InvokeMethod invoke = instruction.asInvokeMethod();
         DexMethod method = invoke.getInvokedMethod();
-        if (method.holder == callerContext.getHolderType()) {
-          DexClass holder = appView.definitionForHolder(method);
-          DexEncodedMethod encodedMethod = method.lookupOnClass(holder);
+        if (method.holder == callerHolder) {
+          DexEncodedMethod encodedMethod = appView.definitionFor(method);
           if (encodedMethod != null && encodedMethod.isPrivateMethod()) {
             // Interface/virtual nest member call to private method,
             // which has now to be a direct call
             // (Now call to same class private method).
             iterator.replaceCurrentInstruction(
                 new InvokeDirect(
-                    method,
-                    invoke.outValue(),
-                    invoke.arguments(),
-                    callerContext.getHolder().isInterface()));
+                    method, invoke.outValue(), invoke.inValues(), callerHolderClass.isInterface()));
           }
         }
       }
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java b/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java
index e03bc6b..c5cd89d 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java
@@ -768,7 +768,9 @@
                   + "$"
                   + method.name.toString());
       DexProto proto =
-          encodedMethod.isStatic() ? method.proto : factory.prependHolderToProto(method);
+          encodedMethod.isStatic()
+              ? method.proto
+              : factory.prependTypeToProto(method.holder, method.proto);
       DexMethod newMethod = factory.createMethod(newHolder, fixupProto(proto), newMethodName);
       lensBuilder.move(method, encodedMethod.isStatic(), newMethod, true);
       encodedMethod.accessFlags.promoteToPublic();
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 79d472d..bd3b4f8 100644
--- a/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
+++ b/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
@@ -997,7 +997,9 @@
                           && !methodPoolForTarget.hasSeen(
                               MethodSignatureEquivalence.get().wrap(method)),
                   Rename.ALWAYS,
-                  appView.dexItemFactory().prependHolderToProto(virtualMethod.getReference()));
+                  appView
+                      .dexItemFactory()
+                      .prependTypeToProto(virtualMethod.holder(), virtualMethod.method.proto));
           makeStatic(resultingDirectMethod);
 
           // Update method pool collection now that we are adding a new public method.
diff --git a/src/main/java/com/android/tools/r8/utils/InternalOptions.java b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
index 35e4614..b42920e 100644
--- a/src/main/java/com/android/tools/r8/utils/InternalOptions.java
+++ b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
@@ -867,7 +867,7 @@
       DexType libraryType,
       DexType invalidSuperType,
       String message,
-      Set<DexEncodedMethod> retarget) {
+      Set<DexMethod> retarget) {
     if (invalidLibraryClasses.add(invalidSuperType)) {
       reporter.warning(
           new InvalidLibrarySuperclassDiagnostic(
@@ -875,7 +875,7 @@
               Reference.classFromDescriptor(libraryType.toDescriptorString()),
               Reference.classFromDescriptor(invalidSuperType.toDescriptorString()),
               message,
-              ListUtils.map(retarget, method -> method.getReference().asMethodReference())));
+              ListUtils.map(retarget, DexMethod::asMethodReference)));
     }
   }