KT-151 Inherit visibility when overriding
#KT-151 Fixed Visibilities.INHERITED constant added (occurs only during resolve), changed after overridden descriptors resolve Fake descriptors are created for invisible properties as well (is necessary for better error reporting)
This commit is contained in:
+8
-4
@@ -18,7 +18,7 @@ open class D {
|
||||
}
|
||||
|
||||
class E : D() {
|
||||
internal <!NOTHING_TO_OVERRIDE!>override<!> fun self() = this
|
||||
internal <!CANNOT_OVERRIDE_INVISIBLE_MEMBER!>override<!> fun self() = this
|
||||
|
||||
fun test() {
|
||||
val <!UNUSED_VARIABLE!>s<!> : E = self()
|
||||
@@ -31,7 +31,11 @@ open class F {
|
||||
}
|
||||
|
||||
class G : F() {
|
||||
<!CANNOT_CHANGE_ACCESS_PRIVILEGE!>override<!> fun protected_fun() {}
|
||||
override fun protected_fun() {}
|
||||
}
|
||||
|
||||
fun test_fun_stays_protected(g: G) {
|
||||
g.<!INVISIBLE_MEMBER!>protected_fun<!>()
|
||||
}
|
||||
|
||||
//------------
|
||||
@@ -57,11 +61,11 @@ trait T {
|
||||
}
|
||||
|
||||
open class L : T {
|
||||
<!CANNOT_WEAKEN_ACCESS_PRIVILEGE!>override<!> fun foo() {}
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class M : L() {
|
||||
internal override fun foo() {}
|
||||
<!CANNOT_WEAKEN_ACCESS_PRIVILEGE!>internal<!> override fun foo() {}
|
||||
}
|
||||
//---------------
|
||||
trait R {
|
||||
@@ -0,0 +1,40 @@
|
||||
//KT-151 Inherit visibility when overriding
|
||||
package kt151
|
||||
|
||||
open class A {
|
||||
protected open fun x() {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun x() {} // No visibility modifier required
|
||||
}
|
||||
|
||||
fun test(b: B) {
|
||||
b.<!INVISIBLE_MEMBER!>x<!>()
|
||||
}
|
||||
|
||||
|
||||
//more tests
|
||||
open class C {
|
||||
internal open fun foo() {}
|
||||
}
|
||||
|
||||
trait T {
|
||||
protected fun foo() {}
|
||||
}
|
||||
|
||||
class D : C(), T {
|
||||
<!CANNOT_CHANGE_ACCESS_PRIVILEGE!>protected<!> override fun foo() {}
|
||||
}
|
||||
|
||||
class E : C(), T {
|
||||
<!CANNOT_CHANGE_ACCESS_PRIVILEGE!>internal<!> override fun foo() {}
|
||||
}
|
||||
|
||||
class F : C(), T {
|
||||
<!CANNOT_WEAKEN_ACCESS_PRIVILEGE!>private<!> override fun foo() {}
|
||||
}
|
||||
|
||||
class G : C(), T {
|
||||
override fun foo() {}
|
||||
}
|
||||
Reference in New Issue
Block a user