From a528638168d994cf37c1a81203db35cc9376d6b4 Mon Sep 17 00:00:00 2001 From: thsaravana Date: Tue, 26 May 2020 10:04:21 +0530 Subject: [PATCH] Validation of VoidReturn for @Binds. Fixes #23 --- .../com/madrapps/dagger/validation/BindsProblem.kt | 1 + .../testData/binds/VoidReturn/KFailureComponent.kt | 13 +++++++++++++ src/test/testData/binds/VoidReturn/VoidReturn.java | 11 +++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/test/testData/binds/VoidReturn/KFailureComponent.kt create mode 100644 src/test/testData/binds/VoidReturn/VoidReturn.java diff --git a/src/main/kotlin/com/madrapps/dagger/validation/BindsProblem.kt b/src/main/kotlin/com/madrapps/dagger/validation/BindsProblem.kt index 91c2d8c..b7cf411 100644 --- a/src/main/kotlin/com/madrapps/dagger/validation/BindsProblem.kt +++ b/src/main/kotlin/com/madrapps/dagger/validation/BindsProblem.kt @@ -38,6 +38,7 @@ object BindsProblem : Problem { this += method.validateCheckedExceptionMethod(range, "@Binds methods may only throw unchecked exceptions. %s not allowed") this += method.validateMultipleScope(range, "@Binds methods cannot use more than one @Scope %s") this += method.validateMultipleQualifier(range, "@Binds methods may not use more than one @Qualifier %s") + this += method.validateVoidReturn(range, "@Binds methods must return a value (not void)") } } } diff --git a/src/test/testData/binds/VoidReturn/KFailureComponent.kt b/src/test/testData/binds/VoidReturn/KFailureComponent.kt new file mode 100644 index 0000000..81ee6ef --- /dev/null +++ b/src/test/testData/binds/VoidReturn/KFailureComponent.kt @@ -0,0 +1,13 @@ +import javax.inject.Inject +import dagger.Module +import dagger.Provides +import dagger.Binds +import assets.Car +import assets.CarImpl + +@Module +abstract class KVoidReturn { + + @Binds + abstract fun getCar(car: CarImpl) +} \ No newline at end of file diff --git a/src/test/testData/binds/VoidReturn/VoidReturn.java b/src/test/testData/binds/VoidReturn/VoidReturn.java new file mode 100644 index 0000000..820369c --- /dev/null +++ b/src/test/testData/binds/VoidReturn/VoidReturn.java @@ -0,0 +1,11 @@ +import dagger.Module; +import dagger.Binds; +import assets.Car; +import assets.CarImpl; + +@Module +public abstract class VoidReturn { + + @Binds + public abstract void getCar(CarImpl car); +} \ No newline at end of file