Always treat all sources as parts of the module being compiled
If a path to the module-info.java file is passed as an argument, we should treat all other source files passed as arguments (either as individual source files or inside a source directory) as members of that module. Previously we treated other source files as members of the unnamed module, and this resulted in incorrect errors when using a member exported with a qualification from another named module, for example #KT-18598 In Fixed
This commit is contained in:
@@ -54,12 +54,14 @@ class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
|
||||
}
|
||||
KotlinTestUtils.compileJavaFilesExternallyWithJava9(javaFiles, javaOptions)
|
||||
},
|
||||
checkKotlinOutput = { actual ->
|
||||
KotlinTestUtils.assertEqualsToFile(File(testDataDirectory, "$name.txt"), actual)
|
||||
}
|
||||
checkKotlinOutput = checkKotlinOutput(name)
|
||||
)
|
||||
}
|
||||
|
||||
private fun checkKotlinOutput(moduleName: String): (String) -> Unit = { actual ->
|
||||
KotlinTestUtils.assertEqualsToFile(File(testDataDirectory, "$moduleName.txt"), actual)
|
||||
}
|
||||
|
||||
fun testSimple() {
|
||||
val a = module("moduleA")
|
||||
module("moduleB", listOf(a))
|
||||
@@ -130,4 +132,21 @@ class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
|
||||
val c = module("moduleC", listOf(a, b))
|
||||
module("moduleD", listOf(c, b, a))
|
||||
}
|
||||
|
||||
fun testSpecifyPathToModuleInfoInArguments() {
|
||||
val a = module("moduleA")
|
||||
|
||||
val jdk9Home = KotlinTestUtils.getJdk9HomeIfPossible() ?: return
|
||||
val kotlinOptions = mutableListOf(
|
||||
"$testDataDirectory/someOtherDirectoryWithTheActualModuleInfo/module-info.java",
|
||||
"-jdk-home", jdk9Home.path,
|
||||
"-Xmodule-path=${a.path}"
|
||||
)
|
||||
compileLibrary(
|
||||
"moduleB",
|
||||
additionalOptions = kotlinOptions,
|
||||
compileJava = { _, _, _ -> error("No .java files in moduleB in this test") },
|
||||
checkKotlinOutput = checkKotlinOutput("moduleB")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user