FIR checker: resolve property with protected getter and public setter

Assuming Java class `Super` has a protected `getName` method and a
public `setName` method.

Then, in a subclass of `Super`, FE1.0 allows calls to `setName` via the
property syntax if the property is protected and invisible due to
dispatch receiver is not `this` or `super`.
This commit is contained in:
Tianyu Geng
2021-09-07 15:14:58 -07:00
committed by TeamCityServer
parent f27f91b03a
commit f35680f0a4
10 changed files with 151 additions and 16 deletions
@@ -0,0 +1,30 @@
// FILE: j/Super.java
package j
public abstract class Super {
protected abstract String getName();
public abstract void setName(String s);
}
// FILE: k/test.kt
package k
import j.Super
abstract class Sub: Super() {
fun test(s: Super) {
s.<!INVISIBLE_REFERENCE!>name<!>
s.<!INVISIBLE_REFERENCE!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_REFERENCE!>name<!>
s.setName("")
}
}
fun test(s: Super) {
s.<!INVISIBLE_REFERENCE!>name<!>
s.<!INVISIBLE_REFERENCE!>getName<!>()
s.name = ""
s.name = s.<!INVISIBLE_REFERENCE!>name<!>
s.setName("")
}
@@ -0,0 +1,30 @@
// FILE: j/Super.java
package j
public abstract class Super {
protected abstract String getName();
public abstract 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("")
}
}
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("")
}
@@ -0,0 +1,27 @@
package
package j {
public abstract class Super {
public constructor Super()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ abstract fun getName(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun setName(/*0*/ s: kotlin.String!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
package k {
public fun test(/*0*/ s: j.Super): kotlin.Unit
public abstract class Sub : j.Super {
public constructor Sub()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ abstract override /*1*/ /*fake_override*/ fun getName(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract override /*1*/ /*fake_override*/ fun setName(/*0*/ s: kotlin.String!): kotlin.Unit
public final fun test(/*0*/ s: j.Super): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -5,8 +5,8 @@ import JavaClass
fun foo(javaClass: JavaClass) {
val v = javaClass.<!INVISIBLE_REFERENCE!>something<!>
javaClass.<!INVISIBLE_REFERENCE!>something<!> = 1
javaClass.<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>something<!>++
javaClass.something = 1
javaClass.<!INVISIBLE_REFERENCE!>something<!>++
}
// FILE: JavaClass.java