Handle absence of no-args constructor for `@ConsiderForDowel`
jayasuryat opened this issue · 1 comments
Currently DowelGenerator
is not considering if the class annotated with @ConsiderForDowel
has a no-args constructor or not. It just assumes such a constructor exists and generates code which tries to invoke a (non-existent) no-args constructor. See here.
DowelGenerator
should handle such cases gracefully and log meaningful errors.
TODO
- Remove strict reliance on the
primary constructor
of the class annotated with@ConsiderForDowel
annotation for object creation. Read more here. - Log error for absence of non-private constructors separately.
- Log error for absence of no-args constructors separately.
- Update processor
tests
for the changes - Update
lint rules
to handle these cases - Update
lint rule
tests
for the changes
Also, Dowel
only considers the primary constructor of the classes annotated with @ConsiderForDowel
annotation. This limitation is not really necessary. All Dowel
cares about is being able to create an instance by calling the invoke method (i.e., ()
ex Provider()
) without passing any parameters. It does not really matter if the corresponding constructor is primary or not, or wether it has default values or not.
So in light of this issue, it would also make sense to lift of this unnecessary limitation