• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Dagger Authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dagger.functional.aot;
18 
19 import dagger.Subcomponent;
20 import javax.inject.Inject;
21 
22 /**
23  * This class demonstrates a regression where a missing binding method was generated in a leaf
24  * component and then satisfied in an ancestor with a generated instance binding. If the ancestor's
25  * generated instance method had the same name as the formerly-missing binding method, Dagger would
26  * generate code without a proper {@code DaggerOuter.this} reference:
27  *
28  * <pre>{@code
29  * public class DaggerAncestor implements Ancestor {
30  *   protected abstract Ancestor getAncestor();
31  *
32  *   protected abstract class LeafImpl extends DaggerLeaf {
33  *     {@literal @Override}
34  *     protected final Ancestor getAncestor() {
35  *       return getAncestor();
36  *       //     ^ should be DaggerAncestor.this.getAncestor()
37  *     }
38  *   }
39  * }
40  * }</pre>
41  */
42 final class MissingBindingReplacedWithGeneratedInstance {
43   @Subcomponent
44   interface Leaf {
dependsOnGeneratedInstance()45     DependsOnGeneratedInstance dependsOnGeneratedInstance();
46   }
47 
48   static class DependsOnGeneratedInstance {
DependsOnGeneratedInstance(Ancestor generatedInstance)49     @Inject DependsOnGeneratedInstance(Ancestor generatedInstance) {}
50   }
51 
52   @Subcomponent
53   interface Ancestor {
child()54     Leaf child();
55   }
56 }
57