Merge "Only rewrite invoke-virtual to invoke-direct if the direct resolution result is on the target of the invoke and *not* a base class."
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 d2ba632..8c1af35 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
@@ -1063,7 +1063,8 @@
       // 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;
-      if (appInfo.lookupDirectTarget(method) != null) {
+      DexEncodedMethod directTarget = appInfo.lookupDirectTarget(method);
+      if (directTarget != null && method.holder == directTarget.method.holder) {
         type = Type.DIRECT;
       }
     }