Has anyone managed to get the TestParameterInjecto...
# test
z
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
e
DefaultConstructorMarker
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
DefaultConstructorMarker
, but a full solution would need to properly understasnd
@kotlin.Metadata
, which would also somewhat tie it to the Kotlin release cycle
z
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.
e
Kotlin allows you to write both
Copy code
constructor(Int)
constructor(UInt)
without collision, but if you were to translate them to Java naively, they both look like
<init>(I)
. 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
Int
, why should there be for
UInt
(or other value classes)?
z
That makes sense, thanks