K2 JVM: implement Java modules-related checkers

All existing tests use custom test data for FIR because the diagnostic
text in FIR has to have a dot at the end. Also, the K2 checker doesn't
check usages in imports because there are no "import checkers" in K2
right now, this will need to be fixed later if necessary.

 #KT-60797 Fixed
This commit is contained in:
Alexander Udalov
2024-02-15 12:50:41 +01:00
committed by Space Team
parent ac901c6d07
commit 5ca7ab9801
23 changed files with 343 additions and 38 deletions
@@ -0,0 +1,4 @@
compiler/testData/javaModules/automaticModuleInternalJdkPackageUsage/jvmStatUsage/Test.kt:1:8: error: symbol is declared in module 'jdk.internal.jvmstat' which does not export package 'sun.jvmstat.monitor'.
val z: sun.jvmstat.monitor.Monitor? = null
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
COMPILATION_ERROR
@@ -0,0 +1,13 @@
compiler/testData/javaModules/noDependencyOnNamed/main/usage.kt:3:15: error: symbol is declared in module 'lib', which the current module does not depend on.
fun test(foo: Foo) {
^^^
compiler/testData/javaModules/noDependencyOnNamed/main/usage.kt:4:9: error: symbol is declared in module 'lib', which the current module does not depend on.
foo.field
^^^^^
compiler/testData/javaModules/noDependencyOnNamed/main/usage.kt:5:9: error: symbol is declared in module 'lib', which the current module does not depend on.
foo.method()
^^^^^^
compiler/testData/javaModules/noDependencyOnNamed/main/usage.kt:6:5: error: symbol is declared in module 'lib', which the current module does not depend on.
Foo()
^^^
COMPILATION_ERROR
@@ -0,0 +1,13 @@
compiler/testData/javaModules/noDependencyOnUnnamed/main/usage.kt:3:15: error: symbol is declared in an unnamed module which is not read by current module.
fun test(foo: Foo) {
^^^
compiler/testData/javaModules/noDependencyOnUnnamed/main/usage.kt:4:9: error: symbol is declared in an unnamed module which is not read by current module.
foo.field
^^^^^
compiler/testData/javaModules/noDependencyOnUnnamed/main/usage.kt:5:9: error: symbol is declared in an unnamed module which is not read by current module.
foo.method()
^^^^^^
compiler/testData/javaModules/noDependencyOnUnnamed/main/usage.kt:6:5: error: symbol is declared in an unnamed module which is not read by current module.
Foo()
^^^
COMPILATION_ERROR
@@ -0,0 +1,37 @@
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:8:9: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val a3: AImpl = A.getInstance()
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:9:18: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val a4: String = AImpl.method()
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:9:24: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val a4: String = AImpl.method()
^^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:10:18: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val a5: String = AImpl.field
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:10:24: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val a5: String = AImpl.field
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:14:9: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val k3: KImpl = K.getInstance()
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:15:18: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val k4: String = KImpl.method()
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:15:24: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val k4: String = KImpl.method()
^^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:16:18: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val k5: String = KImpl.field
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:16:24: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val k5: String = KImpl.field
^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:18:19: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val kf1: String = fileField
^^^^^^^^^
compiler/testData/javaModules/simpleUseNonExportedPackage/moduleB/usage.kt:19:19: error: symbol is declared in module 'moduleA' which does not export package 'a.impl'.
val kf2: String = fileMethod()
^^^^^^^^^^
COMPILATION_ERROR
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,4 @@
compiler/testData/javaModules/unnamedDependsOnNamed/moduleB/usage.kt:7:5: error: symbol is declared in module 'moduleA' which does not export package 'foo.impl'.
Impl() // should be error
^^^^
COMPILATION_ERROR