aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar kmb <kmb@google.com>2018-02-15 10:43:41 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-15 10:45:16 -0800
commitc8e8749adc7b98c272b2421569dc97a88d487771 (patch)
tree169217203a3b86676ddae282f0f9df479eea6116 /src/test/java
parent0588ba0445560ea9503ed623d1f231cb65aa20c8 (diff)
Resolve the owner of interface.super calls to inherited default methods for android desugaring
RELNOTES: None. PiperOrigin-RevId: 185863194
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/DesugarJava8FunctionalTest.java8
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods.java44
-rw-r--r--src/test/java/com/google/devtools/build/android/desugar/testdata_desugared_java8_jar_toc_golden.txt3
3 files changed, 55 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/android/desugar/DesugarJava8FunctionalTest.java b/src/test/java/com/google/devtools/build/android/desugar/DesugarJava8FunctionalTest.java
index 20e60285c0..75d4f43f68 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/DesugarJava8FunctionalTest.java
+++ b/src/test/java/com/google/devtools/build/android/desugar/DesugarJava8FunctionalTest.java
@@ -32,6 +32,7 @@ import com.google.devtools.build.android.desugar.testdata.java8.GenericDefaultIn
import com.google.devtools.build.android.desugar.testdata.java8.InterfaceMethod;
import com.google.devtools.build.android.desugar.testdata.java8.InterfaceWithDefaultMethod;
import com.google.devtools.build.android.desugar.testdata.java8.InterfaceWithDuplicateMethods.ClassWithDuplicateMethods;
+import com.google.devtools.build.android.desugar.testdata.java8.InterfaceWithInheritedMethods;
import com.google.devtools.build.android.desugar.testdata.java8.Java7InterfaceWithBridges;
import com.google.devtools.build.android.desugar.testdata.java8.Named;
import com.google.devtools.build.android.desugar.testdata.java8.TwoInheritedDefaultMethods;
@@ -415,4 +416,11 @@ public class DesugarJava8FunctionalTest extends DesugarFunctionalTest {
assertThat(new DefaultMethodTransitivelyFromSeparateJava8Target().dflt()).isEqualTo("dflt");
assertThat(new DefaultMethodFromSeparateJava8TargetOverridden().dflt()).isEqualTo("override");
}
+
+ /** Regression test for b/73355452 */
+ @Test
+ public void testSuperCallToInheritedDefaultMethod() {
+ assertThat(new InterfaceWithInheritedMethods.Impl().name()).isEqualTo("Base");
+ assertThat(new InterfaceWithInheritedMethods.Impl().suffix()).isEqualTo("!");
+ }
}
diff --git a/src/test/java/com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods.java b/src/test/java/com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods.java
new file mode 100644
index 0000000000..8656e26733
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods.java
@@ -0,0 +1,44 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.android.desugar.testdata.java8;
+
+/** Regression test data for b/73355452 that also includes calling static methods. */
+public interface InterfaceWithInheritedMethods {
+ default String name() {
+ return "Base";
+ }
+
+ static String staticSuffix() {
+ return "!";
+ }
+
+ static interface Passthrough extends InterfaceWithInheritedMethods {
+ // inherits name(). Note that desugar doesn't produce a companion class for this interface
+ // since it doesn't define any default or static interface methods itself.
+ }
+
+ static class Impl implements Passthrough {
+ @Override
+ public String name() {
+ // Even though Passthrough itself doesn't define name(), bytecode refers to Passthrough.name.
+ return Passthrough.super.name();
+ }
+
+ public String suffix() {
+ // Note that Passthrough.defaultSuffix doesn't compile and bytecode refers to
+ // InterfaceWithInheritedMethods.staticSuffix, so this shouldn't cause issues like b/73355452
+ return staticSuffix();
+ }
+ }
+}
diff --git a/src/test/java/com/google/devtools/build/android/desugar/testdata_desugared_java8_jar_toc_golden.txt b/src/test/java/com/google/devtools/build/android/desugar/testdata_desugared_java8_jar_toc_golden.txt
index 67a46c3492..16439aed3f 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/testdata_desugared_java8_jar_toc_golden.txt
+++ b/src/test/java/com/google/devtools/build/android/desugar/testdata_desugared_java8_jar_toc_golden.txt
@@ -82,6 +82,9 @@ com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithDefaultMet
com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithDefaultMethod.class
com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithDuplicateMethods$ClassWithDuplicateMethods.class
com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithDuplicateMethods.class
+com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods$Impl.class
+com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods$Passthrough.class
+com/google/devtools/build/android/desugar/testdata/java8/InterfaceWithInheritedMethods.class
com/google/devtools/build/android/desugar/testdata/java8/Java7InterfaceWithBridges$AbstractClassOne.class
com/google/devtools/build/android/desugar/testdata/java8/Java7InterfaceWithBridges$ClassAddOne.class
com/google/devtools/build/android/desugar/testdata/java8/Java7InterfaceWithBridges$ClassAddTwo.class