1 /* 2 * Copyright (C) 2019 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.kotlin 18 19 import dagger.Component 20 import dagger.Module 21 import dagger.Provides 22 import dagger.functional.kotlin.processor.TriggerGeneratedTypeProcessor 23 import javax.inject.Inject 24 25 @Component(modules = [TestKotlinModuleWithQualifier::class]) 26 interface TestKotlinComponentWithQualifier { injectnull27 fun inject(testInjectedClassWithQualifier: TestMemberInjectedClassWithQualifier) 28 fun inject(fooWithInjectedQualifier: FooWithInjectedQualifier) 29 } 30 31 @Module 32 class TestKotlinModuleWithQualifier { 33 @Provides 34 @JavaTestQualifier 35 fun provideJavaDataA() = TestDataA("test") 36 37 @Provides 38 @JavaTestQualifier 39 fun provideJavaDataB() = TestDataB("test") 40 41 @Provides 42 @JavaTestQualifierWithTarget 43 fun provideJavaWithTargetDataA() = TestDataA("test") 44 45 @Provides 46 @KotlinTestQualifier 47 fun provideKotlinDataA() = TestDataA("test") 48 49 @Provides 50 @JavaTestQualifier 51 fun provideString() = "qualified string" 52 } 53 54 class TestConstructionInjectedClassWithQualifier @Inject constructor( 55 @JavaTestQualifier val data: TestDataA 56 ) 57 58 @TriggerGeneratedTypeProcessor 59 class TestMemberInjectedClassWithQualifier { 60 @Inject 61 @JavaTestQualifier 62 lateinit var javaDataA: TestDataA 63 64 @Inject 65 @field:JavaTestQualifier 66 lateinit var javaDataB: TestDataB 67 68 @Inject 69 @JavaTestQualifierWithTarget 70 lateinit var javaWithTargetDataA: TestDataA 71 72 @Inject 73 @JavaTestQualifier 74 lateinit var kotlinDataA: TestDataA 75 76 @Inject 77 lateinit var dataWithConstructionInjection: TestConstructionInjectedClassWithQualifier 78 79 val noBackingFieldProperty: Int 80 get() = 0 81 <lambda>null82 val delegatedProperty by lazy { "" } 83 84 val generatedTypeProperty = dagger.functional.kotlin.GeneratedType() 85 <lambda>null86 val generatedTypeDelegatedProperty by lazy { dagger.functional.kotlin.GeneratedType() } 87 } 88