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:
+2
@@ -0,0 +1,2 @@
|
||||
module dependency {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package unexported
|
||||
|
||||
class Klass
|
||||
interface Interface
|
||||
|
||||
typealias TypeAliasToPublic = String
|
||||
typealias TypeAliasToUnexported = Klass
|
||||
|
||||
fun function() {}
|
||||
|
||||
val valProperty = ""
|
||||
var varProperty = ""
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module main {
|
||||
requires dependency;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import unexported.*
|
||||
|
||||
fun usage(): String {
|
||||
val k: <error>Klass</error> = <error>Klass</error>()
|
||||
val i: <error>Interface</error>? = null
|
||||
|
||||
val ta1: <error>TypeAliasToPublic</error> = <error>TypeAliasToPublic</error>()
|
||||
val ta2: <error>TypeAliasToUnexported</error> = <error>TypeAliasToUnexported</error>()
|
||||
|
||||
<error>function</error>()
|
||||
|
||||
<error>valProperty</error>
|
||||
<error>varProperty</error>
|
||||
<error>varProperty</error> = ""
|
||||
|
||||
return "$k$i$ta1$ta2"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package dependency;
|
||||
|
||||
public class Foo {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module dependency {
|
||||
exports dependency to first;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import dependency.Foo
|
||||
|
||||
fun firstUsage(): String {
|
||||
val foo: Foo = Foo()
|
||||
return foo.toString()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module first {
|
||||
requires dependency;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module second {
|
||||
requires dependency;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import dependency.<error>Foo</error>
|
||||
|
||||
fun secondUsage(): String {
|
||||
val foo: <error>Foo</error> = <error>Foo</error>()
|
||||
return foo.<error>toString</error>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import dependency.<error>Foo</error>
|
||||
|
||||
fun unnamedUsage(): String {
|
||||
val foo: <error>Foo</error> = <error>Foo</error>()
|
||||
return foo.<error>toString</error>()
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package dependency;
|
||||
|
||||
public class J {
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module main {
|
||||
requires dependency;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import dependency.J
|
||||
|
||||
fun usage(): String {
|
||||
val j: J = J()
|
||||
return j.toString()
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package dependency;
|
||||
|
||||
import dependency.impl.JImpl;
|
||||
|
||||
public class J {
|
||||
public static JImpl getInstance() { return new JImpl(); }
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
package dependency
|
||||
|
||||
import dependency.impl.KImpl
|
||||
|
||||
open class K {
|
||||
companion object {
|
||||
fun getInstance(): KImpl = KImpl()
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package dependency.impl;
|
||||
|
||||
import dependency.J;
|
||||
|
||||
public class JImpl extends J {
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package dependency.impl
|
||||
|
||||
import dependency.K
|
||||
|
||||
class KImpl : K()
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module library {
|
||||
exports dependency;
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module main {
|
||||
requires library;
|
||||
}
|
||||
+16
@@ -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"
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package dependency;
|
||||
|
||||
import dependency.impl.JImpl;
|
||||
|
||||
public class J {
|
||||
public static JImpl getInstance() { return new JImpl(); }
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
package dependency
|
||||
|
||||
import dependency.impl.KImpl
|
||||
|
||||
open class K {
|
||||
companion object {
|
||||
fun getInstance(): KImpl = KImpl()
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package dependency.impl;
|
||||
|
||||
import dependency.J;
|
||||
|
||||
public class JImpl extends J {
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package dependency.impl
|
||||
|
||||
import dependency.K
|
||||
|
||||
class KImpl : K()
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module dependency {
|
||||
exports dependency;
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module main {
|
||||
requires dependency;
|
||||
}
|
||||
+16
@@ -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"
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package dependency;
|
||||
|
||||
import dependency.impl.JImpl;
|
||||
|
||||
public class J {
|
||||
public static JImpl getInstance() { return new JImpl(); }
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
package dependency
|
||||
|
||||
import dependency.impl.KImpl
|
||||
|
||||
open class K {
|
||||
companion object {
|
||||
fun getInstance(): KImpl = KImpl()
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package dependency.impl;
|
||||
|
||||
import dependency.J;
|
||||
|
||||
public class JImpl extends J {
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package dependency.impl
|
||||
|
||||
import dependency.K
|
||||
|
||||
class KImpl : K()
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module dependency {
|
||||
exports dependency;
|
||||
}
|
||||
+16
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user