1 /* 2 * Copyright (C) 2022 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 library1; 18 19 import dagger.BindsInstance; 20 import dagger.Subcomponent; 21 import library2.MyTransitiveAnnotation; 22 import library2.MyTransitiveType; 23 24 /** 25 * A class used to test that Dagger won't fail when non-dagger related annotations cannot be 26 * resolved. 27 * 28 * <p>During the compilation of {@code :app}, {@link MyTransitiveAnnotation} will no longer be on 29 * the classpath. In most cases, Dagger shouldn't care that the annotation isn't on the classpath 30 */ 31 // @MyTransitiveAnnotation: Not yet supported 32 @MyAnnotation(MyTransitiveType.VALUE) 33 @MyOtherAnnotation(MyTransitiveType.class) 34 @MySubcomponentScope 35 @Subcomponent(modules = MySubcomponentModule.class) 36 public abstract class MySubcomponentWithBuilder { 37 @MyQualifier 38 // @MyTransitiveAnnotation: Not yet supported 39 @MyAnnotation(MyTransitiveType.VALUE) 40 @MyOtherAnnotation(MyTransitiveType.class) qualifiedMySubcomponentBinding()41 public abstract MySubcomponentBinding qualifiedMySubcomponentBinding(); 42 43 // @MyTransitiveAnnotation: Not yet supported 44 @MyAnnotation(MyTransitiveType.VALUE) 45 @MyOtherAnnotation(MyTransitiveType.class) unqualifiedMySubcomponentBinding()46 public abstract MySubcomponentBinding unqualifiedMySubcomponentBinding(); 47 48 // @MyTransitiveAnnotation: Not yet supported 49 @MyAnnotation(MyTransitiveType.VALUE) 50 @MyOtherAnnotation(MyTransitiveType.class) injectFoo( @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) Foo foo)51 public abstract void injectFoo( 52 // @MyTransitiveAnnotation: Not yet supported 53 @MyAnnotation(MyTransitiveType.VALUE) @MyOtherAnnotation(MyTransitiveType.class) Foo foo); 54 55 // @MyTransitiveAnnotation: Not yet supported 56 @MyAnnotation(MyTransitiveType.VALUE) 57 @MyOtherAnnotation(MyTransitiveType.class) 58 @Subcomponent.Builder 59 public abstract static class Builder { 60 @MyTransitiveAnnotation 61 @MyAnnotation(MyTransitiveType.VALUE) 62 @MyOtherAnnotation(MyTransitiveType.class) mySubcomponentModule( @yTransitiveAnnotation @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) MySubcomponentModule mySubcomponentModule)63 public abstract Builder mySubcomponentModule( 64 @MyTransitiveAnnotation 65 @MyAnnotation(MyTransitiveType.VALUE) 66 @MyOtherAnnotation(MyTransitiveType.class) 67 MySubcomponentModule mySubcomponentModule); 68 69 @BindsInstance 70 @MyTransitiveAnnotation 71 @MyAnnotation(MyTransitiveType.VALUE) 72 @MyOtherAnnotation(MyTransitiveType.class) qualifiedMySubcomponentBinding( @yQualifier @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) MySubcomponentBinding subcomponentBinding)73 public abstract Builder qualifiedMySubcomponentBinding( 74 @MyQualifier 75 // @MyTransitiveAnnotation: Not yet supported 76 @MyAnnotation(MyTransitiveType.VALUE) 77 @MyOtherAnnotation(MyTransitiveType.class) 78 MySubcomponentBinding subcomponentBinding); 79 80 @BindsInstance 81 @MyTransitiveAnnotation 82 @MyAnnotation(MyTransitiveType.VALUE) 83 @MyOtherAnnotation(MyTransitiveType.class) unqualifiedMySubcomponentBinding( @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) MySubcomponentBinding subcomponentBinding)84 public abstract Builder unqualifiedMySubcomponentBinding( 85 // @MyTransitiveAnnotation: Not yet supported 86 @MyAnnotation(MyTransitiveType.VALUE) @MyOtherAnnotation(MyTransitiveType.class) 87 MySubcomponentBinding subcomponentBinding); 88 89 @MyTransitiveAnnotation 90 @MyAnnotation(MyTransitiveType.VALUE) 91 @MyOtherAnnotation(MyTransitiveType.class) build()92 public abstract MySubcomponentWithBuilder build(); 93 94 // Non-dagger code 95 96 @MyTransitiveAnnotation 97 @MyAnnotation(MyTransitiveType.VALUE) 98 @MyOtherAnnotation(MyTransitiveType.class) 99 public String nonDaggerField = ""; 100 101 @MyTransitiveAnnotation 102 @MyAnnotation(MyTransitiveType.VALUE) 103 @MyOtherAnnotation(MyTransitiveType.class) 104 public static String nonDaggerStaticField = ""; 105 106 @MyTransitiveAnnotation 107 @MyAnnotation(MyTransitiveType.VALUE) 108 @MyOtherAnnotation(MyTransitiveType.class) nonDaggerMethod( @yTransitiveAnnotation @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) String str)109 public void nonDaggerMethod( 110 @MyTransitiveAnnotation 111 @MyAnnotation(MyTransitiveType.VALUE) 112 @MyOtherAnnotation(MyTransitiveType.class) 113 String str) {} 114 115 @MyTransitiveAnnotation 116 @MyAnnotation(MyTransitiveType.VALUE) 117 @MyOtherAnnotation(MyTransitiveType.class) nonDaggerStaticMethod( @yTransitiveAnnotation @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) String str)118 public static void nonDaggerStaticMethod( 119 @MyTransitiveAnnotation 120 @MyAnnotation(MyTransitiveType.VALUE) 121 @MyOtherAnnotation(MyTransitiveType.class) 122 String str) {} 123 } 124 125 // Non-dagger code 126 127 @MyTransitiveAnnotation 128 @MyAnnotation(MyTransitiveType.VALUE) 129 @MyOtherAnnotation(MyTransitiveType.class) 130 public MyTransitiveType nonDaggerField = null; 131 132 @MyTransitiveAnnotation 133 @MyAnnotation(MyTransitiveType.VALUE) 134 @MyOtherAnnotation(MyTransitiveType.class) 135 public static MyTransitiveType nonDaggerStaticField = null; 136 137 @MyTransitiveAnnotation 138 @MyAnnotation(MyTransitiveType.VALUE) 139 @MyOtherAnnotation(MyTransitiveType.class) nonDaggerMethod( @yTransitiveAnnotation @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) MyTransitiveType nonDaggerParameter)140 public MyTransitiveType nonDaggerMethod( 141 @MyTransitiveAnnotation 142 @MyAnnotation(MyTransitiveType.VALUE) 143 @MyOtherAnnotation(MyTransitiveType.class) 144 MyTransitiveType nonDaggerParameter) { 145 return nonDaggerParameter; 146 } 147 148 @MyTransitiveAnnotation 149 @MyAnnotation(MyTransitiveType.VALUE) 150 @MyOtherAnnotation(MyTransitiveType.class) nonDaggerStaticMethod( @yTransitiveAnnotation @yAnnotationMyTransitiveType.VALUE) @yOtherAnnotationMyTransitiveType.class) MyTransitiveType nonDaggerParameter)151 public static MyTransitiveType nonDaggerStaticMethod( 152 @MyTransitiveAnnotation 153 @MyAnnotation(MyTransitiveType.VALUE) 154 @MyOtherAnnotation(MyTransitiveType.class) 155 MyTransitiveType nonDaggerParameter) { 156 return nonDaggerParameter; 157 } 158 } 159