[K/JS] Fix importing behavior for external interfaces in case of implementing them
This commit is contained in:
+8
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.butIf
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
import org.jetbrains.kotlin.utils.memoryOptimizedMap
|
||||
import org.jetbrains.kotlin.utils.memoryOptimizedMapNotNull
|
||||
import org.jetbrains.kotlin.utils.toSmartList
|
||||
|
||||
class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationContext) {
|
||||
@@ -537,8 +538,14 @@ private fun IrOverridableDeclaration<*>.overridesExternal(): Boolean {
|
||||
|
||||
private val IrClassifierSymbol.isInterface get() = (owner as? IrClass)?.isInterface == true
|
||||
|
||||
private fun IrClassSymbol.existsInRuntime(): Boolean {
|
||||
return !owner.isEffectivelyExternal() || !owner.isInterface
|
||||
}
|
||||
|
||||
class JsIrClassModel(val klass: IrClass) {
|
||||
val superClasses = klass.superTypes.memoryOptimizedMap { it.classifierOrNull as IrClassSymbol }
|
||||
val superClasses = klass.superTypes.memoryOptimizedMapNotNull {
|
||||
(it.classifierOrNull as IrClassSymbol).takeIf(IrClassSymbol::existsInRuntime)
|
||||
}
|
||||
|
||||
val preDeclarationBlock = JsCompositeBlock()
|
||||
val postDeclarationBlock = JsCompositeBlock()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// IGNORE_BACKEND: WASM
|
||||
// ES_MODULES
|
||||
// FILE: bar.kt
|
||||
@file:JsModule("./interfaces.mjs")
|
||||
@@ -26,8 +27,16 @@ external val bar: Bar
|
||||
external val baz: Baz
|
||||
|
||||
// FILE: test.kt
|
||||
import boo.Baz
|
||||
|
||||
fun box(): String {
|
||||
if (bar.ping() != "ping" || baz.pong() != 194) return "Fail"
|
||||
|
||||
val local = object : Baz {
|
||||
override fun pong(): Int = 322
|
||||
}
|
||||
|
||||
if (local.asDynamic().pong() != 322) return "Fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user