fix: external declarations in implicit export.
This commit is contained in:
+17
-7
@@ -16,16 +16,14 @@ import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.ES6AddInternalParametersToConstructorPhase.ES6_INIT_BOX_PARAMETER
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.ES6AddInternalParametersToConstructorPhase.ES6_RESULT_TYPE_PARAMETER
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsNameOrKotlinName
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.isExportedInterface
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.isJsExport
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.sanitizeName
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
@@ -34,7 +32,6 @@ class ExportModelGenerator(
|
||||
val context: JsIrBackendContext,
|
||||
val generateNamespacesForPackages: Boolean
|
||||
) {
|
||||
|
||||
fun generateExport(file: IrPackageFragment): List<ExportedDeclaration> {
|
||||
val namespaceFqName = file.fqName
|
||||
val exports = file.declarations.flatMap { declaration -> listOfNotNull(exportDeclaration(declaration)) }
|
||||
@@ -507,8 +504,8 @@ class ExportModelGenerator(
|
||||
|
||||
classifier is IrClassSymbol -> {
|
||||
val klass = classifier.owner
|
||||
val isImplicitlyExported = !klass.isExported(context)
|
||||
val name = if (generateNamespacesForPackages) klass.fqNameWhenAvailable!!.asString() else klass.name.asString()
|
||||
val isImplicitlyExported = !klass.isExported(context) && !klass.isExternal
|
||||
val name = klass.getExportableName()
|
||||
|
||||
when (klass.kind) {
|
||||
ClassKind.ANNOTATION_CLASS,
|
||||
@@ -534,6 +531,19 @@ class ExportModelGenerator(
|
||||
return exportedType.withNullability(isNullable)
|
||||
}
|
||||
|
||||
private fun IrClass.getExportableName(): String {
|
||||
val qualifier = (parent as? IrFile)?.getJsQualifier()
|
||||
val supQualifier = (parent as? IrClass)?.getExportableName()
|
||||
val name = getJsNameOrKotlinName()
|
||||
|
||||
return when {
|
||||
qualifier != null -> "$qualifier.$name"
|
||||
isExternal && !isExported(context) -> "${supQualifier?.plus(".") ?: ""}$name"
|
||||
generateNamespacesForPackages -> fqNameWhenAvailable!!.asString()
|
||||
else -> name.asString()
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrDeclarationWithName.getExportedIdentifier(): String =
|
||||
with(getJsNameOrKotlinName()) {
|
||||
if (isSpecial)
|
||||
|
||||
Reference in New Issue
Block a user