FabricMC / fabric-language-kotlin

Fabric language module for Kotlin.
Apache License 2.0
299 stars 33 forks source link

Top level function reference entry points don't work #120

Closed opekope2 closed 1 year ago

opekope2 commented 1 year ago

As I described it in https://github.com/opekope2/OptiGUI/issues/80#issuecomment-1788893541, when I specify a top level function reference as an entry point. After a recent change in Kotlin reflection (https://github.com/JetBrains/kotlin/commit/5dc882abf5727117d944fddeb934ecf92a8a4927, Kotlin 1.9.20), k.objectInstance returns null instead of throwing UnsupportedOperationException, so KotlinAdapter doesn't fall back to the default adapter.

modmuss50 commented 1 year ago

Uhh, thats a sneaky change. Ill mark FLK with Kotlin 1.9.20 as a beta, and look into fixing this.

opekope2 commented 1 year ago

QKL falls back to the default adapter, if k.objectInstance returns null or throws an exception. Kotlin top level functions will compile to a static method, which works with the default adapter.

modmuss50 commented 1 year ago

I have made a PR for this here: https://github.com/FabricMC/fabric-language-kotlin/pull/121 It seems to solve it. Before I release this I want to test with some other Kotlin mods to ensure I havent broken them.

modmuss50 commented 1 year ago

If you want a jar to test with: https://cdn.discordapp.com/attachments/789950127774105602/1169292378432098394/fabric-language-kotlin-1.10.11kotlin.1.9.20.local.jar