diff --git a/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt b/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt index f3bd7680..99543546 100644 --- a/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt +++ b/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt @@ -155,18 +155,31 @@ class DaggerIssuesDetectorTest : BaseSlackLintTest() { javaxInjectStubs, daggerStubs, kotlin( + "src/foo/TestModule.kt", """ package foo import javax.inject.Qualifier import dagger.Binds import dagger.Module + sealed interface ItemDetail { + object DetailTypeA : ItemDetail + } + + interface ItemMapper + + class DetailTypeAItemMapper : ItemMapper + @Module interface MyModule { @Binds fun validBind(real: Int): Number @Binds fun validBind(real: Boolean): Comparable @Binds fun invalidBind(real: Long): String @Binds fun invalidBind(real: Long): Comparable + + @Binds fun validComplexBinding(real: DetailTypeAItemMapper): ItemMapper + @Binds fun validComplexBinding2(real: DetailTypeAItemMapper): ItemMapper<*> + @Binds fun invalidComplexBinding(real: DetailTypeAItemMapper): ItemMapper } """ ) @@ -176,13 +189,16 @@ class DaggerIssuesDetectorTest : BaseSlackLintTest() { .run() .expect( """ - src/foo/MyModule.kt:10: Error: @Binds function parameters must be type-assignable to their return types. [BindsTypeMismatch] + src/foo/TestModule.kt:18: Error: @Binds function parameters must be type-assignable to their return types. [BindsTypeMismatch] @Binds fun invalidBind(real: Long): String ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - src/foo/MyModule.kt:11: Error: @Binds function parameters must be type-assignable to their return types. [BindsTypeMismatch] + src/foo/TestModule.kt:19: Error: @Binds function parameters must be type-assignable to their return types. [BindsTypeMismatch] @Binds fun invalidBind(real: Long): Comparable ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 2 errors, 0 warnings + src/foo/TestModule.kt:23: Error: @Binds function parameters must be type-assignable to their return types. [BindsTypeMismatch] + @Binds fun invalidComplexBinding(real: DetailTypeAItemMapper): ItemMapper + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 3 errors, 0 warnings """ .trimIndent() )