How come `external` functions don't work in JS/IR?...
# multiplatform
t
How come
external
functions don't work in JS/IR?
Copy code
// 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:
Copy code
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)
e
Better move to #javascript
j
It does, but
external
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
.