Files
kotlin-fork/compiler/testData/diagnostics/tests/properties/protectedGetterWithPublicSetter.kt
T
Kirill Rakhman f6c189be7b FIR: Handle visibility of public setter of protected synthetic property like in K1
K1 allows writing access to a public setter of a protected synthetic
property only if the call is inside a subclass. K2 previously allowed
that unconditionally. This changes brings the behavior in line with K1.

^KT-56050 Fixed
2023-01-26 11:33:30 +00:00

121 lines
3.2 KiB
Kotlin
Vendored

// FILE: j/Super.java
package j
public class Super {
protected String getName() { return "" };
public void setName(String s) { }
}
// FILE: k/test.kt
package k
import j.Super
abstract class Sub : Super() {
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
val anon1 = object : Super() {
fun testAnon() {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
val anon2 = object {
fun testAnon() {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
}
inner class Nested1 : Super() {
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
class Nested2 {
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
}
abstract class NonSub {
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.<!INVISIBLE_MEMBER!>name<!> = ""
s.<!INVISIBLE_MEMBER!>name<!> = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
val anon1 = object : Super() {
fun testAnon() {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
val anon2 = object {
fun testAnon() {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.<!INVISIBLE_MEMBER!>name<!> = ""
s.<!INVISIBLE_MEMBER!>name<!> = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
}
inner class Nested1 : Super() {
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
class Nested2 {
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.<!INVISIBLE_MEMBER!>name<!> = ""
s.<!INVISIBLE_MEMBER!>name<!> = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}
}
}
fun test(s: Super) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>getName<!>()
s.<!INVISIBLE_MEMBER!>name<!> = ""
s.<!INVISIBLE_MEMBER!>name<!> = s.<!INVISIBLE_MEMBER!>name<!>
s.setName("")
}