diff --git a/dev-guide/index.md b/dev-guide/index.md index 9eedc185a31..8502ccb0cf7 100644 --- a/dev-guide/index.md +++ b/dev-guide/index.md @@ -142,8 +142,8 @@ needs the module at compile time, and can avoid class loading the module at runtime. {: .c-callouts__note } -Finally, all `@Provides` methods must belong to a module. These are just classes -that have an [`@Module`][Module] annotation. +Finally, all `@Provides` and `@Binds` methods must belong to a module. These are +just classes that have an [`@Module`][Module] annotation. ```java @Module @@ -152,6 +152,20 @@ interface HeaterModule { } ``` +Note that in Kotlin, `@Provides` methods can also be declared in the companion +object of an `@Module` class. + +```kotlin +@Module +interface HeaterModule { + @Binds fun bindHeater(impl: ElectricHeater): Heater + + companion object { + @Provides fun provideElectricHeater() = ElectricHeater() + } +} +``` + By convention, `@Provides` methods are named with a `provide` prefix, `@Binds` methods are named with `bind` prefix and module classes are named with a `Module` suffix.