diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index 3a6db530a4c..37b2fffb6db 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.* import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.config.ApiVersion +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersion import org.jetbrains.kotlin.config.LanguageVersionSettings @@ -214,6 +215,12 @@ class K2JSCompilerArguments : CommonCompilerArguments() { ) var friendModules: String? by NullableStringFreezableVar(null) + @Argument( + value = "-Xenable-extension-functions-in-externals", + description = "Enable extensions functions members in external interfaces" + ) + var extensionFunctionsInExternals: Boolean by FreezableVar(false) + @Argument(value = "-Xmetadata-only", description = "Generate *.meta.js and *.kjsm files only") var metadataOnly: Boolean by FreezableVar(false) @@ -241,6 +248,14 @@ class K2JSCompilerArguments : CommonCompilerArguments() { ) } } + + override fun configureLanguageFeatures(collector: MessageCollector): MutableMap { + return super.configureLanguageFeatures(collector).apply { + if (extensionFunctionsInExternals) { + this[LanguageFeature.JsEnableExtensionFunctionInExternals] = LanguageFeature.State.ENABLED + } + } + } } fun K2JSCompilerArguments.isPreIrBackendDisabled(): Boolean = diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index eb9e0bf1804..7cea0fb8cc6 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -3,6 +3,8 @@ where advanced options include: -Xcache-directories= A path to cache directories -Xenable-js-scripting Enable experimental support of .kts files using K/JS (with -Xir only) -Xerror-tolerance-policy Set up error tolerance policy (NONE, SEMANTIC, SYNTAX, ALL) + -Xenable-extension-functions-in-externals + Enable extensions functions members in external interfaces -Xfake-override-validator Enable IR fake override validator -Xfriend-modules= Paths to friend modules -Xfriend-modules-disabled Disable internal declaration export