diff --git a/idea/testData/multiplatform/jvmDefaultNonMpp/base/base.kt b/idea/testData/multiplatform/jvmDefaultNonMpp/base/base.kt new file mode 100644 index 00000000000..e87a2d0e5eb --- /dev/null +++ b/idea/testData/multiplatform/jvmDefaultNonMpp/base/base.kt @@ -0,0 +1,9 @@ +package base + +interface Check { + fun test(): String { + return "fail"; + } +} + +open class CheckClass : Check \ No newline at end of file diff --git a/idea/testData/multiplatform/jvmDefaultNonMpp/clash/clash.kt b/idea/testData/multiplatform/jvmDefaultNonMpp/clash/clash.kt new file mode 100644 index 00000000000..5035c4ab88e --- /dev/null +++ b/idea/testData/multiplatform/jvmDefaultNonMpp/clash/clash.kt @@ -0,0 +1,9 @@ +import base.* + +interface SubCheck : Check { + override fun test(): String { + return "OK" + } +} + +class SubCheckClass : CheckClass(), SubCheck \ No newline at end of file diff --git a/idea/testData/multiplatform/jvmDefaultNonMpp/dependencies.txt b/idea/testData/multiplatform/jvmDefaultNonMpp/dependencies.txt new file mode 100644 index 00000000000..faf4ecf9563 --- /dev/null +++ b/idea/testData/multiplatform/jvmDefaultNonMpp/dependencies.txt @@ -0,0 +1,4 @@ +MODULE base { platform=[JVM]; root=base; additionalCompilerArgs=-Xjvm-default=disable } +MODULE clash { platform=[JVM]; root=clash; additionalCompilerArgs=-Xjvm-default=all-compatibility } + +clash -> base { kind=DEPENDS_ON } diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java index abb5597ece5..2c1485338a5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java @@ -153,6 +153,11 @@ public class MultiplatformAnalysisTestGenerated extends AbstractMultiplatformAna runTest("idea/testData/multiplatform/jsNameClash/"); } + @TestMetadata("jvmDefaultNonMpp") + public void testJvmDefaultNonMpp() throws Exception { + runTest("idea/testData/multiplatform/jvmDefaultNonMpp/"); + } + @TestMetadata("lambdas") public void testLambdas() throws Exception { runTest("idea/testData/multiplatform/lambdas/"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/multiplatform/multiPlatformSetup.kt b/idea/tests/org/jetbrains/kotlin/idea/multiplatform/multiPlatformSetup.kt index 91d651bacbf..72e0117e388 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/multiplatform/multiPlatformSetup.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/multiplatform/multiPlatformSetup.kt @@ -115,7 +115,7 @@ fun AbstractMultiModuleTest.doSetup(projectModel: ProjectResolveModel) { pureKotlinSourceFolders = pureKotlinSourceFolders ) // New inference is enabled here as these tests are using type refinement feature that is working only along with NI - ideaModule.enableMultiPlatform(additionalCompilerArguments = "-Xnew-inference") + ideaModule.enableMultiPlatform(additionalCompilerArguments = "-Xnew-inference " + (resolveModule.additionalCompilerArgs ?: "")) } } diff --git a/idea/tests/org/jetbrains/kotlin/projectModel/Model.kt b/idea/tests/org/jetbrains/kotlin/projectModel/Model.kt index fd7ffad47f6..e25f1bd7e24 100644 --- a/idea/tests/org/jetbrains/kotlin/projectModel/Model.kt +++ b/idea/tests/org/jetbrains/kotlin/projectModel/Model.kt @@ -30,7 +30,8 @@ open class ResolveModule( val root: File, val platform: TargetPlatform, val dependencies: List, - val testRoot: File? = null + val testRoot: File? = null, + val additionalCompilerArgs: String? = null ) { final override fun toString(): String { return buildString { renderDescription(Printer(this)) } @@ -43,6 +44,7 @@ open class ResolveModule( printer.println("root=${root.absolutePath}") if (testRoot != null) printer.println("testRoot=${testRoot.absolutePath}") printer.println("dependencies=${dependencies.joinToString { it.to.name }}") + if (additionalCompilerArgs != null) printer.println("additionalCompilerArgs=$additionalCompilerArgs") } override fun equals(other: Any?): Boolean { @@ -69,6 +71,7 @@ open class ResolveModule( var platform: TargetPlatform? = null val dependencies: MutableList = mutableListOf() var testRoot: File? = null + var additionalCompilerArgs: String? = null open fun build(): ResolveModule { if (state == State.BUILT) return cachedResult!! @@ -77,7 +80,7 @@ open class ResolveModule( state = State.BUILDING val builtDependencies = dependencies.map { it.build() } - cachedResult = ResolveModule(name!!, root!!, platform!!, builtDependencies, testRoot) + cachedResult = ResolveModule(name!!, root!!, platform!!, builtDependencies, testRoot, additionalCompilerArgs= additionalCompilerArgs) state = State.BUILT return cachedResult!! diff --git a/idea/tests/org/jetbrains/kotlin/projectModel/Parser.kt b/idea/tests/org/jetbrains/kotlin/projectModel/Parser.kt index 1ca57ed5159..ccace212deb 100644 --- a/idea/tests/org/jetbrains/kotlin/projectModel/Parser.kt +++ b/idea/tests/org/jetbrains/kotlin/projectModel/Parser.kt @@ -70,6 +70,8 @@ open class ProjectStructureParser(private val projectRoot: File) { val root = attributes["root"] ?: builder.name!! builder.root = File(projectRoot, root) + builder.additionalCompilerArgs = attributes["additionalCompilerArgs"] + val testRoot = attributes["testRoot"] if (testRoot != null) builder.testRoot = File(projectRoot, testRoot) } @@ -116,7 +118,7 @@ open class ProjectStructureParser(private val projectRoot: File) { return attributesString .split(ATTRIBUTES_SEPARATOR) - .map { it.splitIntoExactlyTwoParts(ATTRIBUTE_VALUE_SEPARATOR) } + .map { it.splitIntoTwoParts(ATTRIBUTE_VALUE_SEPARATOR) } .toMap() } @@ -202,8 +204,10 @@ private fun Reader.nextWord(): String? { private fun Char.isSeparator() = isWhitespace() || this == '\n' -private fun String.splitIntoExactlyTwoParts(separator: String): Pair { +private fun String.splitIntoTwoParts(separator: String): Pair { val result = split(separator) - require(result.size == 2) { "$this can not be split into exactly two parts with separator $separator" } - return result[0].trim() to result[1].trim() + val name = substringBefore(separator, "") + val value = substringAfter(separator, "") + require(name.isNotEmpty()) { "$this can not be split into two parts with separator $separator" } + return name.trim() to value.trim() } \ No newline at end of file