Tianyu Zhu
08/10/2023, 9:15 PMexternal
functions don't work in JS/IR?
// in one module...
external fun dataProductPlugins(): List<DataProductPlugin>
// in another module...
fun <T> dataProductPlugins(): List<DataProductPlugin> = listOf(
com.tamr.reflex.example.v1.FirstDataProduct.Plugin
)
But then I get this error:
java.lang.IllegalStateException: IrSimpleFunctionPublicSymbolImpl for com.tamr.reflex.v1/dataProductPlugins|-4622519725918523331[0] is already bound: FUN name:dataProductPlugins visibility:public modality:FINAL <T> () returnType:kotlin.collections.List<com.tamr.reflex.v1.DataProductPlugin> [external]
at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.bind(IrPublicSymbolBase.kt:58)
at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl.<init>(IrFunctionImpl.kt:100)
at org.jetbrains.kotlin.ir.declarations.impl.AbstractIrFactoryImpl.createFunction(IrFactoryImpl.kt:129)
at org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImplForJsIC.createFunction(IrFactoryImplForJsIC.kt:181)
Edoardo Luppi
08/11/2023, 7:06 AMJacob Ras
08/11/2023, 7:23 AMexternal
is used to indicate "this code will be available on runtime in JS" (for example, when you import a library yourself and want to talk with it). You're now declaring the same function twice, causing the compiler error. If you want a function with a different implementation per platform you'll need expect/actual
.