Implement Java 9 module visibility checks

In this commit, only IDE tests are added, because we look for module
declarations in the IDE across the whole project, whereas in the
compiler we should do this on the module path only and that requires
separate work (KT-18599) which is done in the following commits.

(The change in Cache.kt is needed so that
JvmModuleAccessibilityChecker.ClassifierUsage, which is an inner class,
would be injected properly.)

 #KT-18598 In Progress
 #KT-18599 In Progress
This commit is contained in:
Alexander Udalov
2017-05-18 19:05:53 +03:00
parent 2275068c94
commit e32880d9a3
56 changed files with 678 additions and 36 deletions

View File

@@ -0,0 +1,7 @@
package dependency;
import dependency.impl.JImpl;
public class J {
public static JImpl getInstance() { return new JImpl(); }
}

View File

@@ -0,0 +1,9 @@
package dependency
import dependency.impl.KImpl
open class K {
companion object {
fun getInstance(): KImpl = KImpl()
}
}

View File

@@ -0,0 +1,6 @@
package dependency.impl;
import dependency.J;
public class JImpl extends J {
}

View File

@@ -0,0 +1,5 @@
package dependency.impl
import dependency.K
class KImpl : K()

View File

@@ -0,0 +1,3 @@
module library {
exports dependency;
}

View File

@@ -0,0 +1,3 @@
module main {
requires library;
}

View File

@@ -0,0 +1,16 @@
import dependency.*
import dependency.J
import dependency.K
import dependency.impl.*
import dependency.impl.<error>JImpl</error>
import dependency.impl.<error>KImpl</error>
fun usage(): String {
val j: J = J.getInstance()
val k: K = K.getInstance()
val jImpl: <error>JImpl</error> = J.getInstance()
val kImpl: <error>KImpl</error> = K.getInstance()
return "$j$k$jImpl$kImpl"
}