Has anyone managed to get the TestParameterInjecto...
# test
Has anyone managed to get the TestParameterInjector constructor injection working with kotlin value classes? It looks like Kotlin generates an additional constructor when there’s a value class in the constructor parameter list, which confuses the library only expecting a single constructor.
I filed an issue about this, but wondering if i missed something
also appears on constructors with default parameters; in that case there's also extra Int parameters acting as bitfields (indicating which parameters are present)
as a hack just for value classes, you could probably just modify that library to ignore synthetic constructors and supply null for
, but a full solution would need to properly understasnd
, which would also somewhat tie it to the Kotlin release cycle
Do you know why this constructor is generated got value classes? It would make some sense to me if the constructors actually had different signatures otherwise, like one took the boxed type and one took the underlying primitive type, but (also something I found surprising) no constructor was generated that took the boxed type.
Kotlin allows you to write both
Copy code
without collision, but if you were to translate them to Java naively, they both look like
. for ordinary functions this is solved by name mangling, but you can't rename constructors, so the only alternative is to mangle the parameter list
there isn't a boxed constructor generated for
, why should there be for
(or other value classes)?
That makes sense, thanks