Revert "Rewrite to invoke-super when target is interface default method" This reverts commit 82710798b61fd70910d76d23a71e436356becb66. Reason for revert: will invoke-super on private interface methods Change-Id: I71854aa39e4f993d73b01d623d206f83046caeaa
diff --git a/src/main/java/com/android/tools/r8/cf/code/CfInvoke.java b/src/main/java/com/android/tools/r8/cf/code/CfInvoke.java index 794d913..2cca2a8 100644 --- a/src/main/java/com/android/tools/r8/cf/code/CfInvoke.java +++ b/src/main/java/com/android/tools/r8/cf/code/CfInvoke.java
@@ -141,21 +141,10 @@ } case Opcodes.INVOKESPECIAL: { - // Per https://source.android.com/devices/tech/dalvik/dalvik-bytecode, for Dex files - // version >= 037, if the method refers to an interface method, invoke-super is used to - // invoke the most specific, non-overridden version of that method. - // In https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.3, it is - // a compile-time error in the case that "If TypeName denotes an interface, let T be the - // type declaration immediately enclosing the method invocation. A compile-time error - // occurs if there exists a method, distinct from the compile-time declaration, that - // overrides (§9.4.1) the compile-time declaration from a direct superclass or - // direct superinterface of T." - // Using invoke-super should therefore observe the correct semantics since we cannot - // target less specific targets (up in the hierarchy). canonicalMethod = method; if (method.name.toString().equals(Constants.INSTANCE_INITIALIZER_NAME)) { type = Type.DIRECT; - } else if (code.getOriginalHolder() == method.holder && !this.itf) { + } else if (code.getOriginalHolder() == method.holder) { type = Type.DIRECT; } else { type = Type.SUPER;
diff --git a/src/test/java/com/android/tools/r8/desugaring/interfacemethods/InterfaceMethodDesugaringTests.java b/src/test/java/com/android/tools/r8/desugaring/interfacemethods/InterfaceMethodDesugaringTests.java index 7151dfa..a6ee6a5 100644 --- a/src/test/java/com/android/tools/r8/desugaring/interfacemethods/InterfaceMethodDesugaringTests.java +++ b/src/test/java/com/android/tools/r8/desugaring/interfacemethods/InterfaceMethodDesugaringTests.java
@@ -55,6 +55,9 @@ com.android.tools.r8.desugaring.interfacemethods.test0.InterfaceWithDefaults.class))); } + // NOTE: this particular test is working on pre-N devices since + // it's fixed by interface default method desugaring. + @IgnoreForRangeOfVmVersions(from = Version.V7_0_0, to = Version.DEFAULT) @Test public void testInvokeSpecialToDefaultMethodFromStatic() throws Exception { ensureSameOutput(
diff --git a/src/test/java/com/android/tools/r8/desugaring/interfacemethods/test0/TestMain.java b/src/test/java/com/android/tools/r8/desugaring/interfacemethods/test0/TestMain.java index b977b54..79ac7b0 100644 --- a/src/test/java/com/android/tools/r8/desugaring/interfacemethods/test0/TestMain.java +++ b/src/test/java/com/android/tools/r8/desugaring/interfacemethods/test0/TestMain.java
@@ -10,7 +10,6 @@ System.out.println("TestMain::test()"); this.foo(); this.bar(); - InterfaceWithDefaults.super.foo(); } @Override