1 /* 2 * Copyright (C) 2021 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 app 18 19 import dagger.Component 20 import dagger.assisted.Assisted 21 import dagger.assisted.AssistedFactory 22 import dagger.assisted.AssistedInject 23 import javax.inject.Inject 24 25 // This is a regression test for https://github.com/google/dagger/issues/2309 26 /** A simple, skeletal application that defines an assisted inject binding. */ 27 class AssistedInjectClasses { 28 @Component 29 interface MyComponent { fooFactorynull30 fun fooFactory(): FooFactory 31 32 fun parameterizedFooFactory(): ParameterizedFooFactory<Bar, String> 33 } 34 35 class Bar @Inject constructor() 36 37 class Foo @AssistedInject constructor(val bar: Bar, @Assisted val assistedStr: String) 38 39 @AssistedFactory 40 interface FooFactory { 41 fun create(str: String): Foo 42 } 43 44 class ParameterizedFoo<T1, T2> 45 @AssistedInject 46 constructor(val t1: T1, @Assisted val assistedT2: T2) 47 48 @AssistedFactory 49 interface ParameterizedFooFactory<T1, T2> { createnull50 fun create(t2: T2): ParameterizedFoo<T1, T2> 51 } 52 } 53