From 0b484771dd4d8c686e83b9c3f9eb417e724d4324 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Mon, 23 Oct 2017 16:24:12 +0300 Subject: [PATCH] Add compiler key to enable new inference --- .../cli/common/arguments/CommonCompilerArguments.kt | 8 +++++++- .../src/org/jetbrains/kotlin/cli/common/CLICompiler.java | 4 ++++ compiler/testData/cli/js/jsExtraHelp.out | 1 + compiler/testData/cli/jvm/extraHelp.out | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 0b9859cba2c..3eca4a481ab 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * 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. @@ -106,6 +106,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) var coroutinesState: String? by FreezableVar(WARN) + @Argument( + value = "-Xnew-inference", + description = "Enable new experimental generic type inference algorithm" + ) + var newInference: Boolean by FreezableVar(false) + open fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> { return HashMap, Any>().apply { put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java index ad6240a5de4..e5e98df6af1 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java @@ -204,6 +204,10 @@ public abstract class CLICompiler extends CLI extraLanguageFeatures.put(LanguageFeature.Coroutines, coroutinesState); } + if (arguments.getNewInference()) { + extraLanguageFeatures.put(LanguageFeature.NewInference, LanguageFeature.State.ENABLED); + } + setupPlatformSpecificLanguageFeatureSettings(extraLanguageFeatures, arguments); CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, new LanguageVersionSettingsImpl( diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index f66cdb961f9..b2537f72e14 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -8,6 +8,7 @@ where advanced options include: Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier -Xintellij-plugin-root= Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found -Xmulti-platform Enable experimental language support for multi-platform projects + -Xnew-inference Enable new experimental generic type inference algorithm -Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects -Xno-inline Disable method inlining -Xplugin= Load plugins from the given classpath diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 3792f66e16f..9dfb64ff290 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -35,6 +35,7 @@ where advanced options include: Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier -Xintellij-plugin-root= Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found -Xmulti-platform Enable experimental language support for multi-platform projects + -Xnew-inference Enable new experimental generic type inference algorithm -Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects -Xno-inline Disable method inlining -Xplugin= Load plugins from the given classpath