mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-12 15:53:40 +00:00
Effective visibility mechanism introduced. Local is considered as public, java protected as Kotlin protected, java package private as Kotlin private.
55 lines
1.1 KiB
Kotlin
Vendored
55 lines
1.1 KiB
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
|
|
|
//FILE:file1.kt
|
|
package a
|
|
|
|
private open class A {
|
|
fun bar() {}
|
|
}
|
|
|
|
private var x: Int = 10
|
|
|
|
var xx: Int = 20
|
|
private set(value: Int) {}
|
|
|
|
private fun foo() {}
|
|
|
|
private fun bar() {
|
|
val y = x
|
|
x = 20
|
|
xx = 30
|
|
}
|
|
|
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>makeA<!>() = A()
|
|
|
|
private object PO {}
|
|
|
|
//FILE:file2.kt
|
|
package a
|
|
|
|
fun test() {
|
|
val y = makeA()
|
|
y.<!INVISIBLE_MEMBER(A; private; file)!>bar<!>()
|
|
<!INVISIBLE_MEMBER(foo; private; file)!>foo<!>()
|
|
|
|
val u : <!INVISIBLE_REFERENCE(A; private; file)!>A<!> = <!INVISIBLE_MEMBER(A; private; file)!>A<!>()
|
|
|
|
val z = <!INVISIBLE_MEMBER(x; private; file)!>x<!>
|
|
<!INVISIBLE_MEMBER(x; private; file)!>x<!> = 30
|
|
|
|
val po = <!INVISIBLE_MEMBER(PO; private; file)!>PO<!>
|
|
|
|
val v = xx
|
|
<!INVISIBLE_SETTER(xx; private; file)!>xx<!> = 40
|
|
}
|
|
|
|
class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_REFERENCE(A; private; file), INVISIBLE_MEMBER(A; private; file)!>A<!>()<!> {}
|
|
|
|
class Q {
|
|
class W {
|
|
fun foo() {
|
|
val y = makeA() //assure that 'makeA' is visible
|
|
}
|
|
}
|
|
}
|