Skip to content

Commit

Permalink
Validation of VoidReturn for @BINDS. Fixes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
thsaravana committed May 26, 2020
1 parent 2e91b34 commit a528638
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
}
}
13 changes: 13 additions & 0 deletions src/test/testData/binds/VoidReturn/KFailureComponent.kt
Original file line number Diff line number Diff line change
@@ -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 {

@<error descr="@Binds methods must return a value (not void)">Binds</error>
abstract fun getCar(car: CarImpl)
}
11 changes: 11 additions & 0 deletions src/test/testData/binds/VoidReturn/VoidReturn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import dagger.Module;
import dagger.Binds;
import assets.Car;
import assets.CarImpl;

@Module
public abstract class VoidReturn {

@<error descr="@Binds methods must return a value (not void)">Binds</error>
public abstract void getCar(CarImpl car);
}

0 comments on commit a528638

Please sign in to comment.