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:
+3
@@ -0,0 +1,3 @@
|
||||
package foo;
|
||||
|
||||
public class Foo {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module moduleA {
|
||||
exports foo to moduleB;
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package unexported;
|
||||
|
||||
public class Unexported {}
|
||||
@@ -0,0 +1,10 @@
|
||||
compiler/testData/javaModules/specifyPathToModuleInfoInArguments/moduleB/usage.kt:2:19: error: symbol is declared in module 'moduleA' which does not export package 'unexported'
|
||||
import unexported.Unexported
|
||||
^
|
||||
compiler/testData/javaModules/specifyPathToModuleInfoInArguments/moduleB/usage.kt:9:5: error: symbol is declared in module 'moduleA' which does not export package 'unexported'
|
||||
Unexported()
|
||||
^
|
||||
compiler/testData/javaModules/specifyPathToModuleInfoInArguments/moduleB/usage.kt:13:5: error: unresolved reference: Unrelated
|
||||
Unrelated()
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import foo.Foo
|
||||
import unexported.Unexported
|
||||
|
||||
fun usage() {
|
||||
// Should be OK
|
||||
Foo()
|
||||
|
||||
// Should be error
|
||||
Unexported()
|
||||
|
||||
// Should be error: if we're passing the path to a particular module-info.java to the compiler,
|
||||
// we should not treat its location as a root
|
||||
Unrelated()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
public class Unrelated {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module moduleB {
|
||||
requires moduleA;
|
||||
}
|
||||
Reference in New Issue
Block a user