• 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  * The test classes for desugaring default methods. Desugar is not expected to generate companion
18  * classes for interfaces without default methods. The bridge methods are automatically generated by
19  * javac and put in the implementing classes.
20  *
21  * <p>NOTE: There should be NO companion class generated for this class.
22  */
23 public interface Java7InterfaceWithBridges<T> {
add(T value)24   T add(T value);
25 
26   /** Concretize T to {@link Number)} */
27   interface LevelOne<T extends Number> extends Java7InterfaceWithBridges<T> {
28     @Override
add(T value)29     T add(T value);
30   }
31 
32   /** Concretize to {@link Integer} */
33   interface LevelTwo extends LevelOne<Integer> {
34     @Override
add(Integer value)35     Integer add(Integer value);
36   }
37 
38   /** Empty abstract class. This class should have no bridge methods */
39   abstract static class AbstractClassOne implements LevelTwo {}
40 
41   /** Implementing class. */
42   static class ClassAddOne extends AbstractClassOne {
43     @Override
add(Integer value)44     public Integer add(Integer value) {
45       return value + 1;
46     }
47   }
48 
49   /** Implementing class. */
50   static class ClassAddTwo extends AbstractClassOne implements LevelTwo {
51     @Override
add(Integer value)52     public Integer add(Integer value) {
53       return value + 2;
54     }
55   }
56 }
57