[JS IR] Export type for enum class and not extends kotlin.Enum in TS

^KT-37916 fixed
^KT-44494 fixed
This commit is contained in:
Ilya Goncharov
2021-10-21 19:21:35 +03:00
committed by Space
parent 817e3dc306
commit 69f6dc059d
@@ -226,7 +226,7 @@ class ExportModelGenerator(
// TODO: Handle non-exported super types
val superType = klass.superTypes
.firstOrNull { !it.classifierOrFail.isInterface && !it.isAny() }
.firstOrNull { !it.classifierOrFail.isInterface && it.canBeUsedAsSuperTypeOfExportedClasses() }
?.let { exportType(it).takeIf { it !is ExportedType.ErrorType } }
val superInterfaces = klass.superTypes
@@ -271,6 +271,9 @@ class ExportModelGenerator(
)
}
private fun IrType.canBeUsedAsSuperTypeOfExportedClasses(): Boolean =
!this.isAny() && classifierOrNull != context.irBuiltIns.enumClass
private fun exportTypeArgument(type: IrTypeArgument): ExportedType {
if (type is IrTypeProjection)
return exportType(type.type)
@@ -328,7 +331,6 @@ class ExportModelGenerator(
when (klass.kind) {
ClassKind.ANNOTATION_CLASS,
ClassKind.ENUM_CLASS,
ClassKind.ENUM_ENTRY ->
ExportedType.ErrorType("Class $name with kind: ${klass.kind}")
@@ -336,6 +338,7 @@ class ExportModelGenerator(
ExportedType.TypeOf(name)
ClassKind.CLASS,
ClassKind.ENUM_CLASS,
ClassKind.INTERFACE -> ExportedType.ClassType(
name,
type.arguments.map { exportTypeArgument(it) }