Actually make sure that we only rewrite invoke-virtual if targeting a method in the current class.

R=sgjesse@google.com, zerny@google.com

Change-Id: Iedf3d07fd6b42a2b876e22820c02f8fc45665dc6
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java b/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
index 8c1af35..c697105 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
@@ -1062,10 +1062,12 @@
       // not apply (see jvm spec on method resolution 5.4.3.3 and overriding 5.4.5) and
       // therefore we use an invoke-direct instead. We need to do this as the Android Runtime
       // will not allow invoke-virtual of a private method.
-      DexMethod method = (DexMethod) item;
-      DexEncodedMethod directTarget = appInfo.lookupDirectTarget(method);
-      if (directTarget != null && method.holder == directTarget.method.holder) {
-        type = Type.DIRECT;
+      DexMethod invocationMethod = (DexMethod) item;
+      if (invocationMethod.holder == method.method.holder) {
+        DexEncodedMethod directTarget = appInfo.lookupDirectTarget(invocationMethod);
+        if (directTarget != null && invocationMethod.holder == directTarget.method.holder) {
+          type = Type.DIRECT;
+        }
       }
     }
     add(Invoke.create(type, item, callSiteProto, null, arguments, itf));