Is there a way to inject a `value class` with Dagg...
# dagger
d
Is there a way to inject a
value class
with Dagger2? It seems like it's not working... (don't think it makes a difference, but I'm using Anvil with it...)
e
as long as Dagger is using (K)APT and generating Java, probably not
d
Yeah, I guess that makes sense... but under the hood doesn't a value class compile to a Java value class, or is Kapt not smart enough?
e
under the hood, a
@JvmInline value class Value(val value: T)
compiles to a combination of things: • properties, variables, methods, constructors, etc. declared as type
Value
compile to directly use
T
, but with mangled names to avoid collisions with Java overloads on
T
• a wrapper class
Value
for use in contexts where the above can't work (e.g.
List<Value>
), with boxing/unboxing-like operations around its use for now, all Kotlin/JVM value classes must be `@JvmInline`; Java's Project Valhalla is not ready and thus there are no JVM primitive classes yet. there isn't a lot that KAPT can sensibly do with value classes - the mangled names aren't valid Java identifiers
🙏 2