Disable New Inference in JS backend
See #KT-37163 for details
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.js
|
||||
|
||||
import org.jetbrains.kotlin.config.*
|
||||
|
||||
class JSLanguageVersionSettings(private val delegate: LanguageVersionSettings) : LanguageVersionSettings {
|
||||
companion object {
|
||||
private val disabledFeatures = setOf(
|
||||
LanguageFeature.NewInference,
|
||||
LanguageFeature.FunctionalInterfaceConversion,
|
||||
LanguageFeature.SamConversionForKotlinFunctions,
|
||||
LanguageFeature.SamConversionPerArgument,
|
||||
LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType,
|
||||
LanguageFeature.NonStrictOnlyInputTypesChecks
|
||||
)
|
||||
}
|
||||
|
||||
override fun getFeatureSupport(feature: LanguageFeature): LanguageFeature.State {
|
||||
return if (feature in disabledFeatures)
|
||||
LanguageFeature.State.DISABLED
|
||||
else
|
||||
delegate.getFeatureSupport(feature)
|
||||
}
|
||||
|
||||
override fun isPreRelease(): Boolean = delegate.isPreRelease()
|
||||
|
||||
override fun <T> getFlag(flag: AnalysisFlag<T>): T = delegate.getFlag(flag)
|
||||
|
||||
override val apiVersion: ApiVersion
|
||||
get() = delegate.apiVersion
|
||||
|
||||
override val languageVersion: LanguageVersion
|
||||
get() = delegate.languageVersion
|
||||
}
|
||||
@@ -246,6 +246,13 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, FileUtil.getNameWithoutExtension(outputFile));
|
||||
|
||||
if (!arguments.getNewInference()) {
|
||||
CommonConfigurationKeysKt.setLanguageVersionSettings(
|
||||
configuration,
|
||||
new JSLanguageVersionSettings(CommonConfigurationKeysKt.getLanguageVersionSettings(configuration))
|
||||
);
|
||||
}
|
||||
|
||||
JsConfig config = new JsConfig(project, configuration);
|
||||
JsConfig.Reporter reporter = new JsConfig.Reporter() {
|
||||
@Override
|
||||
|
||||
@@ -24,10 +24,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageUtil
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
$TESTDATA_DIR$/reifiedIntersectionType.kt
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test1() {
|
||||
val flow = combine(
|
||||
flowOf("1"),
|
||||
flowOf(2)
|
||||
) { arr -> arr.joinToString() }
|
||||
}
|
||||
|
||||
fun <T> Array<out T>.joinToString(): String = ""
|
||||
|
||||
public inline fun <reified T, R> combine(
|
||||
vararg flows: Flow<T>,
|
||||
crossinline transform: suspend (Array<T>) -> R
|
||||
): Flow<R> = TODO()
|
||||
|
||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||
interface Flow<out T>
|
||||
@@ -0,0 +1,13 @@
|
||||
compiler/testData/cli/js/reifiedIntersectionType.kt:2:9: warning: variable 'flow' is never used
|
||||
val flow = combine(
|
||||
^
|
||||
compiler/testData/cli/js/reifiedIntersectionType.kt:11:12: warning: parameter 'flows' is never used
|
||||
vararg flows: Flow<T>,
|
||||
^
|
||||
compiler/testData/cli/js/reifiedIntersectionType.kt:12:17: warning: parameter 'transform' is never used
|
||||
crossinline transform: suspend (Array<T>) -> R
|
||||
^
|
||||
compiler/testData/cli/js/reifiedIntersectionType.kt:15:16: warning: parameter 'value' is never used
|
||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||
^
|
||||
OK
|
||||
@@ -0,0 +1,37 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
// Case that was found in kotlinx.coroutines
|
||||
|
||||
fun test1() {
|
||||
val flow = combine(
|
||||
flowOf("1"),
|
||||
flowOf(2)
|
||||
) { arr -> arr.joinToString() }
|
||||
}
|
||||
|
||||
fun <T> Array<out T>.joinToString(): String = ""
|
||||
|
||||
public inline fun <reified T, R> combine(
|
||||
vararg flows: Flow<T>,
|
||||
crossinline transform: suspend (Array<T>) -> R
|
||||
): Flow<R> = TODO()
|
||||
|
||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||
interface Flow<out T>
|
||||
|
||||
// Simplified case
|
||||
|
||||
class In<in T>
|
||||
|
||||
inline fun <reified K> select(x: K, y: K): K = x
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun test2(a: In<A>, b: In<B>) {
|
||||
select(a, b)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+NewInference
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+SamConversionForKotlinFunctions
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+SamConversionPerArgument
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -Xnew-inference
|
||||
|
||||
package common
|
||||
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+NewInference
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+SamConversionForKotlinFunctions
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+SamConversionPerArgument
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -Xnew-inference
|
||||
|
||||
package js
|
||||
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+NewInference
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+SamConversionForKotlinFunctions
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -XXLanguage:+SamConversionPerArgument
|
||||
// ADDITIONAL_COMPILER_ARGUMENTS: -Xnew-inference
|
||||
|
||||
package jvm
|
||||
|
||||
|
||||
@@ -1,41 +1,11 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:+NewInference
|
||||
-XXLanguage:+SamConversionForKotlinFunctions
|
||||
-XXLanguage:+SamConversionPerArgument
|
||||
|
||||
This mode is not recommended for production use,
|
||||
as no stability/compatibility guarantees are given on
|
||||
compiler or generated code. Use it at your own risk!
|
||||
|
||||
-- JVM --
|
||||
Exit code: OK
|
||||
Output:
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:+NewInference
|
||||
-XXLanguage:+SamConversionForKotlinFunctions
|
||||
-XXLanguage:+SamConversionPerArgument
|
||||
|
||||
This mode is not recommended for production use,
|
||||
as no stability/compatibility guarantees are given on
|
||||
compiler or generated code. Use it at your own risk!
|
||||
|
||||
-- JS --
|
||||
Exit code: OK
|
||||
Output:
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:+NewInference
|
||||
-XXLanguage:+SamConversionForKotlinFunctions
|
||||
-XXLanguage:+SamConversionPerArgument
|
||||
|
||||
This mode is not recommended for production use,
|
||||
as no stability/compatibility guarantees are given on
|
||||
compiler or generated code. Use it at your own risk!
|
||||
|
||||
@@ -888,6 +888,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/js/outputPrefixFileNotFound.args");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.args")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/cli/js/reifiedIntersectionType.args");
|
||||
}
|
||||
|
||||
@TestMetadata("simple2js.args")
|
||||
public void testSimple2js() throws Exception {
|
||||
runTest("compiler/testData/cli/js/simple2js.args");
|
||||
|
||||
+5
@@ -26549,6 +26549,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedInlineIntoNonInlineableLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.kt")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedIntersectionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safecast.kt")
|
||||
public void testSafecast() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/safecast.kt");
|
||||
|
||||
+5
@@ -25366,6 +25366,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedInlineIntoNonInlineableLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.kt")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedIntersectionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safecast.kt")
|
||||
public void testSafecast() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/safecast.kt");
|
||||
|
||||
+5
@@ -25048,6 +25048,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedInlineIntoNonInlineableLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.kt")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedIntersectionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safecast.kt")
|
||||
public void testSafecast() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/safecast.kt");
|
||||
|
||||
+5
@@ -25048,6 +25048,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedInlineIntoNonInlineableLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.kt")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedIntersectionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safecast.kt")
|
||||
public void testSafecast() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/safecast.kt");
|
||||
|
||||
Generated
+5
@@ -20484,6 +20484,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.kt")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedIntersectionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safecast.kt")
|
||||
public void testSafecast() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/safecast.kt");
|
||||
|
||||
+5
@@ -20544,6 +20544,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reifiedIntersectionType.kt")
|
||||
public void testReifiedIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/reifiedIntersectionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safecast.kt")
|
||||
public void testSafecast() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reified/safecast.kt");
|
||||
|
||||
Reference in New Issue
Block a user