Reputation: 1773
Here is what we know from the docs: getter of public
property can't be private (seems logical enough), so:
@Inject
var repository: MyExampleRepository? = null
private get
won't compile.
Ok, so maybe we can make property private
and define setter public
?
@Inject
private var repository: MyExampleRepository? = null
public set
This will compile and value will actually be injected, but I still can't use this in code, so:
service.repository = null
gives compilation error:
Kotlin: Cannot access 'repository': it is 'private' in 'MyService'
I wonder if it is possible to have private property with public setter.
Upvotes: 3
Views: 459