FIR: Support inferring PRIVATE_TO_THIS visibility see KT-49875

This commit is contained in:
Mikhail Glukhikh
2022-07-11 18:05:06 +02:00
committed by Space
parent 3b613b3745
commit 83200f8774
10 changed files with 150 additions and 9 deletions
@@ -0,0 +1,14 @@
// FIR_DUMP
class A<in T>(t: T) {
private val t: T = t // PRIVATE_TO_THIS
fun test() {
val x: T = t // Ok
val y: T = this.t // Ok
}
fun foo(a: A<String>) {
val x: String = a.t // Invisible!
}
}
@@ -0,0 +1,19 @@
FILE: privateToThis.fir.kt
public final class A<in T> : R|kotlin/Any| {
public constructor<in T>(t: R|T|): R|A<T>| {
super<R|kotlin/Any|>()
}
private/*private to this*/ final val t: R|T| = R|<local>/t|
private/*private to this*/ get(): R|T|
public final fun test(): R|kotlin/Unit| {
lval x: R|T| = this@R|/A|.R|/A.t|
lval y: R|T| = this@R|/A|.R|/A.t|
}
public final fun foo(a: R|A<kotlin/String>|): R|kotlin/Unit| {
lval x: R|kotlin/String| = R|<local>/a|.R|SubstitutionOverride</A.t: R|kotlin/String|>|
}
}
@@ -0,0 +1,14 @@
// FIR_DUMP
class A<in T>(t: T) {
private val t: T = t // PRIVATE_TO_THIS
fun test() {
val x: T = t // Ok
val y: T = this.t // Ok
}
fun foo(a: A<String>) {
val x: String = a.<!INVISIBLE_MEMBER!>t<!> // Invisible!
}
}
@@ -0,0 +1,11 @@
package
public final class A</*0*/ in T> {
public constructor A</*0*/ in T>(/*0*/ t: T)
private/*private to this*/ final val t: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ a: A<kotlin.String>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}