diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/JsToStringGenerationVisitor.java b/js/js.ast/src/org/jetbrains/kotlin/js/backend/JsToStringGenerationVisitor.java index 975a816639e..e4f93583afa 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/JsToStringGenerationVisitor.java +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/JsToStringGenerationVisitor.java @@ -731,11 +731,6 @@ public class JsToStringGenerationVisitor extends JsVisitor { p.print(""); } - @Override - public void visitProgramFragment(@NotNull JsProgramFragment x) { - p.print(""); - } - @Override public void visitRegExp(@NotNull JsRegExp x) { slash(); diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsClassModel.kt b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsClassModel.kt new file mode 100644 index 00000000000..05fb1be5c76 --- /dev/null +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsClassModel.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.js.backend.ast + +class JsClassModel(val name: JsName, val superName: JsName?) diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsImportedModule.kt b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsImportedModule.kt new file mode 100644 index 00000000000..f4bad4540e8 --- /dev/null +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsImportedModule.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.js.backend.ast + +class JsImportedModule(val externalName: String, val internalName: JsName, val plainReference: JsExpression?) { + val key = JsImportedModuleKey(externalName, plainReference?.toString()) +} + +data class JsImportedModuleKey(val baseName: String, val plainName: String?) \ No newline at end of file diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsNameBinding.kt b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsNameBinding.kt new file mode 100644 index 00000000000..7985fc1d0c6 --- /dev/null +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsNameBinding.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.js.backend.ast + +class JsNameBinding(val key: String, val name: JsName) \ No newline at end of file diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgram.java b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgram.java index c15ad24c3ef..1cbe6db24b3 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgram.java +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgram.java @@ -17,8 +17,7 @@ import java.util.Map; * A JavaScript program. */ public final class JsProgram extends SourceInfoAwareJsNode { - - private JsProgramFragment[] fragments; + private final JsGlobalBlock globalBlock = new JsGlobalBlock(); private final TDoubleObjectHashMap doubleLiteralMap = new TDoubleObjectHashMap(); private final TIntObjectHashMap intLiteralMap = new TIntObjectHashMap(); @@ -30,18 +29,10 @@ public final class JsProgram extends SourceInfoAwareJsNode { public JsProgram() { rootScope = new JsRootScope(this); topScope = new JsObjectScope(rootScope, "Global"); - setFragmentCount(1); } - public JsBlock getFragmentBlock(int fragment) { - if (fragment < 0 || fragment >= fragments.length) { - throw new IllegalArgumentException("Invalid fragment: " + fragment); - } - return fragments[fragment].getGlobalBlock(); - } - - public JsBlock getGlobalBlock() { - return getFragmentBlock(0); + public JsGlobalBlock getGlobalBlock() { + return globalBlock; } public JsNumberLiteral getNumberLiteral(double value) { @@ -94,13 +85,6 @@ public final class JsProgram extends SourceInfoAwareJsNode { return literal; } - public void setFragmentCount(int fragments) { - this.fragments = new JsProgramFragment[fragments]; - for (int i = 0; i < fragments; i++) { - this.fragments[i] = new JsProgramFragment(); - } - } - @Override public void accept(JsVisitor v) { v.visitProgram(this); @@ -108,17 +92,13 @@ public final class JsProgram extends SourceInfoAwareJsNode { @Override public void acceptChildren(JsVisitor visitor) { - for (JsProgramFragment fragment : fragments) { - visitor.accept(fragment); - } + visitor.accept(globalBlock); } @Override public void traverse(JsVisitorWithContext v, JsContext ctx) { if (v.visit(this, ctx)) { - for (JsProgramFragment fragment : fragments) { - v.accept(fragment); - } + v.accept(globalBlock); } v.endVisit(this, ctx); } diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgramFragment.java b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgramFragment.java index 3e251368710..2cbc34a92ea 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgramFragment.java +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsProgramFragment.java @@ -6,41 +6,59 @@ package org.jetbrains.kotlin.js.backend.ast; import org.jetbrains.annotations.NotNull; -/** - * One independently loadable fragment of a {@link JsProgram}. - */ -public class JsProgramFragment extends SourceInfoAwareJsNode { - private final JsGlobalBlock globalBlock; +import java.util.*; - public JsProgramFragment() { - globalBlock = new JsGlobalBlock(); - } +public class JsProgramFragment { + private final JsScope scope; + private final List importedModules = new ArrayList(); + private final Map imports = new LinkedHashMap(); + private final JsGlobalBlock declarationBlock = new JsGlobalBlock(); + private final JsGlobalBlock exportBlock = new JsGlobalBlock(); + private final JsGlobalBlock initializerBlock = new JsGlobalBlock(); + private final List nameBindings = new ArrayList(); + private final Map classes = new LinkedHashMap(); - public JsBlock getGlobalBlock() { - return globalBlock; - } - - @Override - public void accept(JsVisitor v) { - v.visitProgramFragment(this); - } - - @Override - public void acceptChildren(JsVisitor visitor) { - visitor.accept(globalBlock); - } - - @Override - public void traverse(JsVisitorWithContext v, JsContext ctx) { - if (v.visit(this, ctx)) { - v.acceptStatement(globalBlock); - } - v.endVisit(this, ctx); + public JsProgramFragment(@NotNull JsScope scope) { + this.scope = scope; } @NotNull - @Override - public JsProgramFragment deepCopy() { - throw new UnsupportedOperationException(); + public JsScope getScope() { + return scope; + } + + @NotNull + public List getImportedModules() { + return importedModules; + } + + @NotNull + public Map getImports() { + return imports; + } + + @NotNull + public JsBlock getDeclarationBlock() { + return declarationBlock; + } + + @NotNull + public JsGlobalBlock getExportBlock() { + return exportBlock; + } + + @NotNull + public JsGlobalBlock getInitializerBlock() { + return initializerBlock; + } + + @NotNull + public List getNameBindings() { + return nameBindings; + } + + @NotNull + public Map getClasses() { + return classes; } } diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitor.kt b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitor.kt index 37a6fda485e..fd92725a925 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitor.kt +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitor.kt @@ -120,9 +120,6 @@ abstract class JsVisitor { open fun visitProgram(x: JsProgram): Unit = visitElement(x) - open fun visitProgramFragment(x: JsProgramFragment): Unit = - visitElement(x) - open fun visitPropertyInitializer(x: JsPropertyInitializer): Unit = visitElement(x) diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java index 7a7d1b9f6d0..dda50198b7e 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java @@ -152,9 +152,6 @@ public abstract class JsVisitorWithContext { public void endVisit(@NotNull JsProgram x, @NotNull JsContext ctx) { } - public void endVisit(@NotNull JsProgramFragment x, @NotNull JsContext ctx) { - } - public void endVisit(@NotNull JsPropertyInitializer x, @NotNull JsContext ctx) { } @@ -312,10 +309,6 @@ public abstract class JsVisitorWithContext { return true; } - public boolean visit(@NotNull JsProgramFragment x, @NotNull JsContext ctx) { - return true; - } - public boolean visit(@NotNull JsPropertyInitializer x, @NotNull JsContext ctx) { return true; } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt index 23e0373729a..b04f9454c8c 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt @@ -399,7 +399,6 @@ internal open class JsExpressionVisitor() : JsVisitorWithContextImpl() { override fun visit(x: JsFunction, ctx: JsContext): Boolean = false override fun visit(x: JsObjectLiteral, ctx: JsContext): Boolean = false override fun visit(x: JsPropertyInitializer, ctx: JsContext): Boolean = false - override fun visit(x: JsProgramFragment, ctx: JsContext): Boolean = false override fun visit(x: JsProgram, ctx: JsContext): Boolean = false override fun visit(x: JsParameter, ctx: JsContext): Boolean = false override fun visit(x: JsCatch, ctx: JsContext): Boolean = false diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java index f109059e6f8..07a4b3bd75b 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java @@ -16,6 +16,8 @@ package org.jetbrains.kotlin.js.facade; +import org.jetbrains.kotlin.js.backend.ast.JsImportedModule; +import org.jetbrains.kotlin.js.backend.ast.JsProgram; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.ModuleDescriptor; @@ -97,7 +99,7 @@ public final class K2JSTranslator { ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); List importedModules = new ArrayList<>(); - for (StaticContext.ImportedModule module : context.getImportedModules()) { + for (JsImportedModule module : context.getImportedModules()) { importedModules.add(module.getExternalName()); } return new TranslationResult.Success(config, files, program, diagnostics, importedModules, moduleDescriptor, diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/JsSourceGenerationVisitor.java b/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/JsSourceGenerationVisitor.java index fe668853405..64fa108330e 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/JsSourceGenerationVisitor.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/JsSourceGenerationVisitor.java @@ -37,11 +37,6 @@ public class JsSourceGenerationVisitor extends JsToStringGenerationVisitor imple out.setOutListener(this); } - @Override - public void visitProgramFragment(@NotNull JsProgramFragment x) { - x.acceptChildren(this); - } - @Override public void newLined() { if (sourceMapBuilder != null) { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java index fbd295c701b..8dd8d106dea 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java @@ -125,9 +125,9 @@ public final class StaticContext { private final Map fqnCache = new HashMap<>(); @NotNull - private final Map importedModules = new LinkedHashMap<>(); + private final Map importedModules = new LinkedHashMap<>(); - private Collection readOnlyImportedModules; + private Collection readOnlyImportedModules; @NotNull private final JsScope rootPackageScope; @@ -175,8 +175,8 @@ public final class StaticContext { rootPackageScope = new JsObjectScope(rootScope, ""); JsName kotlinName = rootScope.declareName(Namer.KOTLIN_NAME); - importedModules.put(new ImportedModuleKey(Namer.KOTLIN_LOWER_NAME, null), - new ImportedModule(Namer.KOTLIN_LOWER_NAME, kotlinName, null)); + importedModules.put(new JsImportedModuleKey(Namer.KOTLIN_LOWER_NAME, null), + new JsImportedModule(Namer.KOTLIN_LOWER_NAME, kotlinName, null)); } @NotNull @@ -205,7 +205,7 @@ public final class StaticContext { } @NotNull - public Collection getImportedModules() { + public Collection getImportedModules() { if (readOnlyImportedModules == null) { readOnlyImportedModules = Collections.unmodifiableCollection(importedModules.values()); } @@ -286,7 +286,7 @@ public final class StaticContext { if (config.getModuleKind() != ModuleKind.PLAIN) { String moduleName = AnnotationsUtils.getModuleName(suggested.getDescriptor()); if (moduleName != null) { - return JsAstUtils.pureFqn(getImportedModule(moduleName, suggested.getDescriptor()).internalName, null); + return JsAstUtils.pureFqn(getImportedModule(moduleName, suggested.getDescriptor()).getInternalName(), null); } } @@ -308,7 +308,7 @@ public final class StaticContext { if (isNativeObject(suggested.getDescriptor()) && DescriptorUtils.isTopLevelDeclaration(suggested.getDescriptor())) { String fileModuleName = AnnotationsUtils.getFileModuleName(getBindingContext(), suggested.getDescriptor()); if (fileModuleName != null) { - JsName moduleJsName = getImportedModule(fileModuleName, null).internalName; + JsName moduleJsName = getImportedModule(fileModuleName, null).getInternalName(); expression = pureFqn(moduleJsName, expression); } @@ -484,8 +484,8 @@ public final class StaticContext { private JsName localOrImportedName(@NotNull DeclarationDescriptor descriptor, @NotNull String suggestedName) { ModuleDescriptor module = DescriptorUtilsKt.getModule(descriptor); JsName name = module != currentModule ? - importDeclaration(suggestedName, getQualifiedReference(descriptor)) : - rootFunction.getScope().declareTemporaryName(suggestedName); + importDeclaration(suggestedName, getQualifiedReference(descriptor)) : + rootFunction.getScope().declareTemporaryName(suggestedName); MetadataProperties.setDescriptor(name, descriptor); return name; } @@ -667,15 +667,14 @@ public final class StaticContext { } @NotNull - private ImportedModule getImportedModule(@NotNull String baseName, @Nullable DeclarationDescriptor descriptor) { - JsName plainName = descriptor != null && config.getModuleKind() == ModuleKind.UMD ? - rootScope.declareName(getPlainId(descriptor)) : null; - ImportedModuleKey key = new ImportedModuleKey(baseName, plainName); + private JsImportedModule getImportedModule(@NotNull String baseName, @Nullable DeclarationDescriptor descriptor) { + String plainName = descriptor != null && config.getModuleKind() == ModuleKind.UMD ? getPlainId(descriptor) : null; + JsImportedModuleKey key = new JsImportedModuleKey(baseName, plainName); - ImportedModule module = importedModules.get(key); + JsImportedModule module = importedModules.get(key); if (module == null) { JsName internalName = rootScope.declareTemporaryName(Namer.LOCAL_MODULE_PREFIX + Namer.suggestedModuleName(baseName)); - module = new ImportedModule(baseName, internalName, plainName != null ? pureFqn(plainName, null) : null); + module = new JsImportedModule(baseName, internalName, plainName != null ? pureFqn(plainName, null) : null); importedModules.put(key, module); } return module; @@ -692,7 +691,7 @@ public final class StaticContext { if (descriptor instanceof FunctionDescriptor || descriptor instanceof PackageFragmentDescriptor || descriptor instanceof ClassDescriptor - ) { + ) { MetadataProperties.setSideEffects(expression, SideEffectKind.PURE); } return expression; @@ -805,69 +804,4 @@ public final class StaticContext { } return false; } - - public static class ImportedModule { - @NotNull - private final String externalName; - - @NotNull - private final JsName internalName; - - @Nullable - private final JsExpression plainReference; - - ImportedModule(@NotNull String externalName, @NotNull JsName internalName, @Nullable JsExpression plainReference) { - this.externalName = externalName; - this.internalName = internalName; - this.plainReference = plainReference; - } - - @NotNull - public String getExternalName() { - return externalName; - } - - @NotNull - public JsName getInternalName() { - return internalName; - } - - @Nullable - public JsExpression getPlainReference() { - return plainReference; - } - } - - private static class ImportedModuleKey { - @NotNull - private final String baseName; - - @Nullable - private final JsName plainName; - - public ImportedModuleKey(@NotNull String baseName, @Nullable JsName plainName) { - this.baseName = baseName; - this.plainName = plainName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ImportedModuleKey key = (ImportedModuleKey) o; - - if (!baseName.equals(key.baseName)) return false; - if (plainName != null ? !plainName.equals(key.plainName) : key.plainName != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = baseName.hashCode(); - result = 31 * result + (plainName != null ? plainName.hashCode() : 0); - return result; - } - } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java index b521dfb93ef..10ccd4c76ee 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java @@ -126,7 +126,7 @@ public class TranslationContext { } @NotNull - public Collection getImportedModules() { + public Collection getImportedModules() { return staticContext.getImportedModules(); } @@ -544,7 +544,7 @@ public class TranslationContext { if (result == null && classOrConstructor instanceof ConstructorDescriptor && ((ConstructorDescriptor) classOrConstructor).isPrimary() - ) { + ) { result = staticContext.getClassOrConstructorClosure((ClassDescriptor) classOrConstructor.getContainingDeclaration()); } return result; diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/ModuleWrapperTranslation.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/ModuleWrapperTranslation.kt index b92f5007635..955902053d0 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/ModuleWrapperTranslation.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/ModuleWrapperTranslation.kt @@ -18,13 +18,12 @@ package org.jetbrains.kotlin.js.translate.general import org.jetbrains.kotlin.js.backend.ast.* import org.jetbrains.kotlin.js.translate.context.Namer -import org.jetbrains.kotlin.js.translate.context.StaticContext import org.jetbrains.kotlin.js.translate.utils.JsAstUtils import org.jetbrains.kotlin.serialization.js.ModuleKind object ModuleWrapperTranslation { @JvmStatic fun wrapIfNecessary( - moduleId: String, function: JsExpression, importedModules: List, + moduleId: String, function: JsExpression, importedModules: List, program: JsProgram, kind: ModuleKind ): List { return when (kind) { @@ -37,7 +36,7 @@ object ModuleWrapperTranslation { private fun wrapUmd( moduleId: String, function: JsExpression, - importedModules: List, program: JsProgram + importedModules: List, program: JsProgram ): List { val scope = program.scope val defineName = scope.declareName("define") @@ -79,7 +78,7 @@ object ModuleWrapperTranslation { private fun wrapAmd( function: JsExpression, - importedModules: List, program: JsProgram + importedModules: List, program: JsProgram ): List { val scope = program.scope val defineName = scope.declareName("define") @@ -94,7 +93,7 @@ object ModuleWrapperTranslation { private fun wrapCommonJs( function: JsExpression, - importedModules: List, + importedModules: List, program: JsProgram ): List { val scope = program.scope @@ -108,7 +107,7 @@ object ModuleWrapperTranslation { private fun wrapPlain( moduleId: String, function: JsExpression, - importedModules: List, program: JsProgram + importedModules: List, program: JsProgram ): List { val invocation = makePlainInvocation(moduleId, function, importedModules, program) val statements = mutableListOf() @@ -130,7 +129,7 @@ object ModuleWrapperTranslation { private fun addModuleValidation( currentModuleId: String, program: JsProgram, - module: StaticContext.ImportedModule + module: JsImportedModule ): JsStatement { val moduleRef = makePlainModuleRef(module, program) val moduleExistsCond = JsAstUtils.typeOfIs(moduleRef, program.getStringLiteral("undefined")) @@ -144,7 +143,7 @@ object ModuleWrapperTranslation { private fun makePlainInvocation( moduleId: String, function: JsExpression, - importedModules: List, + importedModules: List, program: JsProgram ): JsInvocation { val invocationArgs = importedModules.map { makePlainModuleRef(it, program) } @@ -155,7 +154,7 @@ object ModuleWrapperTranslation { return JsInvocation(function, listOf(selfArg) + invocationArgs) } - private fun makePlainModuleRef(module: StaticContext.ImportedModule, program: JsProgram): JsExpression { + private fun makePlainModuleRef(module: JsImportedModule, program: JsProgram): JsExpression { return module.plainReference ?: makePlainModuleRef(module.externalName, program) } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java index 9917a7acb57..6567f660222 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java @@ -283,9 +283,9 @@ public final class Translation { // Invoke function passing modules as arguments // This should help minifier tool to recognize references to these modules as local variables and make them shorter. - List importedModuleList = new ArrayList<>(); + List importedModuleList = new ArrayList<>(); - for (StaticContext.ImportedModule importedModule : staticContext.getImportedModules()) { + for (JsImportedModule importedModule : staticContext.getImportedModules()) { rootFunction.getParameters().add(new JsParameter(importedModule.getInternalName())); importedModuleList.add(importedModule); }