[JS IR] Export nested objects

Companion objects are exported as ParentClass.Companion.
Companion object's members are not exposed to its parent class —
one must reference the companion object explicitly if they want to
access its members.

#KT-43783 Fixed
This commit is contained in:
Sergej Jaskiewicz
2021-08-26 16:30:23 +03:00
committed by TeamCityServer
parent 862f8cdad8
commit be999564b1
7 changed files with 83 additions and 3 deletions
@@ -86,9 +86,15 @@ class ExportModelToJsStatements(
)
).makeStmt()
// These are only used when exporting secondary constructors annotated with @JsName
val staticFunctions = declaration.members.filter { it is ExportedFunction && it.isStatic }
val staticsExport = (staticFunctions + declaration.nestedClasses)
// Nested objects are exported as static properties
val staticProperties = declaration.members.mapNotNull {
(it as? ExportedProperty)?.takeIf { it.isStatic }
}
val staticsExport = (staticFunctions + staticProperties + declaration.nestedClasses)
.flatMap { generateDeclarationExport(it, newNameSpace) }
listOf(klassExport) + staticsExport