ARRRG, why does this compile but still show me red...
# multiplatform
j
ARRRG, why does this compile but still show me red on android studio. The code compiles and runs fine (ignore the cast, its incorrect)
j
Full reflection only works on the JVM/Android and presumably you're in a multiplatform context with targets other than those two.
j
Ok well thats a design flaw, if thats the case, which it is, then this code should not compile at all, and it should not let me add reflection to my common source set. Poor poor design
🫤 1
j
Common is not a target though
Common code only makes sense when projected into a target
If you only compile for one target, otherwise invalid code can compile
j
right, i have it projected into IOS, Android and Desktop, even though I dont use IOS
normally this would result in my code failing to build at all, which is the correct way to go about this. Also, why in the god damn hell is something as essential as reflection broken on IOS?
j
It's not broken, it's absent. And it's full reflection, not all reflection
j
yes full reflection is super important for making things like serializers and what not
j
Reflection is only one mechanism of metaprogramming things like serialization
1
j
if you want JSON -> POJO its the way to go, furthermore its a first party kotlin library
j
It's a way to go, sure
j
how else will you get POJO working?
j
You could use kotlinx.serialization which introspects types at compile time and generated descriptors of their properties which can be used at runtime
☝️ 3
☝🏾 1
There's many forms of code generation that are used to aid in runtime serialization
j
doesnt kotlinx use full reflection ?
j
It does not use any reflection
2
x
In Kotlin multiplatform project, if you want to use reflection, try to use ksp/kcp to instead.
j
whats kcp?
j
Kotlin compiler plugin
j
So this creates a symbol file for kotlin? sounds cool