Join Slack
Powered by
A question about Reflexion in Kotlin. Are all clas...
# announcements
p
pablisco
09/03/2017, 11:54 PM
A question about Reflexion in Kotlin. Are all classes in Kotlin static? For some reason I found myself the other day porting the TypeToken of Gson into Kotlin. (I think I almost got it) But when I went to run the test:
https://github.com/google/gson/blob/master/gson/src/test/java/com/google/gson/internal/GsonTypesTest.java#L40
If fails to throw an exception because for some reason D::class.java is always static. Are all the types in Kotlin compiled down to static classes? It’s a bit strange, I was expecting to be failing somewhere else. Here is what I’ve done so far, in case someone has better eyes than me 🙂
https://gist.github.com/pablisco/b21070d6df6622f529e639dbabdb2af1
g
gildor
09/04/2017, 1:32 AM
Nested classes in Kotlin are static by default. To make it non static add modifier
inner
You can check docs -
https://kotlinlang.org/docs/reference/nested-classes.html#inner-classes
p
pablisco
09/04/2017, 6:32 AM
Sweet, I'll try that for the tests. Cheers
pablisco
09/04/2017, 8:48 AM
@gildor
That worked, amazing. thanks 🍻
🍺 1
Open in Slack
Previous
Next