Marc Knaup
02/18/2021, 5:19 PM-Xir-property-lazy-initialization
.
With -Xir-per-module
I need to know if a certain module was already loaded. The only which comes to mind is to set a global variable when loading that module, and check if that variable set from other modules.Svyatoslav Kuzmich [JB]
02/18/2021, 6:21 PMimport kotlin.test.Test
class Foo {
@Test
fun foo() {
thisModuleIsLoaded = true
}
}
// At most one main function per module
fun main() {
thisModuleIsLoaded = true
}
Marc Knaup
03/15/2021, 4:11 PM-Xir-per-module
.
The main
functions of modules get dead-code-eliminated.
I can force-keep it with with @JsExport
but then I run into another issue because multiple modules export a symbol with the same name `main`:
IllegalStateException: IrSimpleFunctionPublicSymbolImpl for public /main|-4284757841571462650[0] is already bound: FUN name:main visibility:public modality:FINAL <> () returnType:<Uninitialized>
Any other ideas how to run code when such a module loads?Marc Knaup
03/15/2021, 4:13 PMmain
funs need to be private
😮
@JsExport private fun main()