diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index 80563561f5e..1bcda00d3a0 100644 --- a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -20,6 +20,7 @@ import com.google.common.collect.Lists import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.testFramework.LightVirtualFile @@ -707,6 +708,34 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { result.assertSuccessful() } + /* + * Here we're checking that enabling inference in IDE doesn't affect compilation via JPS + * + * the following two tests are connected: + * - testKotlinProjectWithEnabledNewInferenceInIDE checks that project is compiled when new inference is enabled only in IDE + * - this is done via project component + * - testKotlinProjectWithErrorsBecauseOfNewInference checks that project isn't compiled when new inference is enabled in the compiler + * + * So, if the former will fail => option affects JPS compilation, it's bad. Also, if the latter test fails => test is useless as it's + * compiled with new and old inference. + * + */ + fun testKotlinProjectWithEnabledNewInferenceInIDE() { + doTest() + } + + fun testKotlinProjectWithErrorsBecauseOfNewInference() { + initProject(JVM_MOCK_RUNTIME) + val module = myProject.modules.single() + val args = module.kotlinCompilerArguments + args.newInference = true + myProject.kotlinCommonCompilerArguments = args + + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + private fun createKotlinJavaScriptLibraryArchive() { val jarFile = File(workDir, KOTLIN_JS_LIBRARY_JAR) try { diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/kotlinProject.ipr new file mode 100644 index 00000000000..f04957c330e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/src/test1.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/src/test1.kt new file mode 100644 index 00000000000..5f41546490a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEnabledNewInferenceInIDE/src/test1.kt @@ -0,0 +1,5 @@ +fun foo() { + ByteArray(42) { + when (Any()) {} + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/errors.txt b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/errors.txt new file mode 100644 index 00000000000..df2e59d5fe9 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/errors.txt @@ -0,0 +1 @@ +Type mismatch: inferred type is Unit but Byte was expected at line 3, column 9 diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/src/test1.kt b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/src/test1.kt new file mode 100644 index 00000000000..5f41546490a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithErrorsBecauseOfNewInference/src/test1.kt @@ -0,0 +1,5 @@ +fun foo() { + ByteArray(42) { + when (Any()) {} + } +} \ No newline at end of file