• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Bazel Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 package com.google.devtools.build.android.desugar.testdata.java8;
15 
16 /**
17  * Test for b/38308515. This interface has one instance method {@code m()} and one static method
18  * {@code m(InterfaceWithDuplicateMethods)}, which may cause Desugar to dump a companion class with
19  * duplicate method signatures.
20  */
21 public interface InterfaceWithDuplicateMethods {
22 
23   /**
24    * In the companion class, this default method will be transformed to {@code int
25    * getZero(InterfaceWithDuplicateMethods)}, which has the same signature as the static interface
26    * method below.
27    */
28   @SuppressWarnings("AmbiguousMethodReference")
getZero()29   default int getZero() {
30     return 0;
31   }
32 
33   /** Should not be called. Should only be called by the class {@link ClassWithDuplicateMethods} */
34   @SuppressWarnings("AmbiguousMethodReference")
getZero(InterfaceWithDuplicateMethods i)35   static int getZero(InterfaceWithDuplicateMethods i) {
36     return 1;
37   }
38 
39   /** This class implements the interface, and calls the static interface method. */
40   class ClassWithDuplicateMethods implements InterfaceWithDuplicateMethods {
getZeroFromStaticInterfaceMethod()41     public int getZeroFromStaticInterfaceMethod() {
42       return InterfaceWithDuplicateMethods.getZero(this);
43     }
44   }
45 }
46