[FIR] Fix visibility issues with private members within inner and anonymous scopes ^KT-49992 Fixed

This commit is contained in:
Ivan Kochurkin
2021-12-01 16:57:27 +03:00
committed by Space
parent 800d594a4f
commit f68c8f8f01
11 changed files with 390 additions and 35 deletions
-3
View File
@@ -1,6 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: NPE: null cannot be cast to not-null type IrPropertySymbol
// while translating this@R|/<anonymous>|.R|/X.n|
open class X(private val n: String) {
fun foo(): String {
@@ -0,0 +1,76 @@
// KT-49992
import kotlin.reflect.KFunction0
open class A {
private val x: String? = null
fun test0() {
x
this.x
}
open class Nested : A() {
private val y: String? = null
fun test1(): String? = <!INVISIBLE_REFERENCE!>x<!>
fun test2(): String? = this.<!INVISIBLE_REFERENCE!>x<!>
class NestedInNested : Nested() {
fun test20(): String? = <!INVISIBLE_REFERENCE!>y<!>
fun test21(): String? = this.<!INVISIBLE_REFERENCE!>y<!>
}
inner class InnerInNested : Nested() {
fun test23(): String? = y
fun test24(): String? = this.<!INVISIBLE_REFERENCE!>y<!>
}
}
interface I {
fun test401(): KFunction0<Unit>
}
open inner class Inner : A(), I {
private val y: String? = null
fun test3(): String? = x
fun test4(): String? = this.<!INVISIBLE_REFERENCE!>x<!>
inner class InnerInInner : Inner() {
fun test40(): String? = x
fun test41(): String? = y
}
private fun test400() {
}
override fun test401(): KFunction0<Unit> {
return this::test400
}
}
fun test5() {
object : A() {
fun local() {
x
this.<!INVISIBLE_REFERENCE!>x<!>
}
inner class NestedInAnonymous() {
fun test50(): String? = x
}
}
}
}
fun A.extensionFun(): String? = this.<!INVISIBLE_REFERENCE!>x<!>
abstract class B<T: B<T>> {
protected abstract val thisBuilder: T
private val x: String? = null
fun test6(obj: Any?) = thisBuilder.apply {
obj?.let { this.x }
}
}
@@ -0,0 +1,76 @@
// KT-49992
import kotlin.reflect.KFunction0
open class A {
private val x: String? = null
fun test0() {
x
this.x
}
open class Nested : A() {
private val y: String? = null
fun test1(): String? = <!INVISIBLE_MEMBER!>x<!>
fun test2(): String? = this.<!INVISIBLE_MEMBER!>x<!>
class NestedInNested : Nested() {
fun test20(): String? = <!INVISIBLE_MEMBER!>y<!>
fun test21(): String? = this.<!INVISIBLE_MEMBER!>y<!>
}
inner class InnerInNested : Nested() {
fun test23(): String? = y
fun test24(): String? = this.<!INVISIBLE_MEMBER!>y<!>
}
}
interface I {
fun test401(): KFunction0<Unit>
}
open inner class Inner : A(), I {
private val y: String? = null
fun test3(): String? = x
fun test4(): String? = this.<!INVISIBLE_MEMBER!>x<!>
inner class InnerInInner : Inner() {
fun test40(): String? = x
fun test41(): String? = y
}
private fun test400() {
}
override fun test401(): KFunction0<Unit> {
return this::test400
}
}
fun test5() {
object : A() {
fun local() {
x
this.<!INVISIBLE_MEMBER!>x<!>
}
inner class NestedInAnonymous() {
fun test50(): String? = x
}
}
}
}
fun A.extensionFun(): String? = this.<!INVISIBLE_MEMBER!>x<!>
abstract class B<T: B<T>> {
protected abstract val thisBuilder: T
private val x: String? = null
fun test6(obj: Any?) = thisBuilder.apply {
obj?.let { this.x }
}
}
@@ -0,0 +1,106 @@
package
public fun A.extensionFun(): kotlin.String?
public open class A {
public constructor A()
private final val x: kotlin.String? = null
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test0(): kotlin.Unit
public final fun test5(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public interface I {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun test401(): kotlin.reflect.KFunction0<kotlin.Unit>
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open inner class Inner : A, A.I {
public constructor Inner()
invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String?
private final val y: kotlin.String? = null
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit
public final fun test3(): kotlin.String?
public final fun test4(): kotlin.String?
private final fun test400(): kotlin.Unit
public open override /*1*/ fun test401(): kotlin.reflect.KFunction0<kotlin.Unit>
public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
public final inner class InnerInInner : A.Inner {
public constructor InnerInInner()
invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String?
invisible_fake final override /*1*/ /*fake_override*/ val y: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit
public final override /*1*/ /*fake_override*/ fun test3(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test4(): kotlin.String?
public final fun test40(): kotlin.String?
invisible_fake final override /*1*/ /*fake_override*/ fun test400(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun test401(): kotlin.reflect.KFunction0<kotlin.Unit>
public final fun test41(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public open class Nested : A {
public constructor Nested()
invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String?
private final val y: kotlin.String? = null
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit
public final fun test1(): kotlin.String?
public final fun test2(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final inner class InnerInNested : A.Nested {
public constructor InnerInNested()
invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String?
invisible_fake final override /*1*/ /*fake_override*/ val y: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit
public final override /*1*/ /*fake_override*/ fun test1(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test2(): kotlin.String?
public final fun test23(): kotlin.String?
public final fun test24(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class NestedInNested : A.Nested {
public constructor NestedInNested()
invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.String?
invisible_fake final override /*1*/ /*fake_override*/ val y: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun test0(): kotlin.Unit
public final override /*1*/ /*fake_override*/ fun test1(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test2(): kotlin.String?
public final fun test20(): kotlin.String?
public final fun test21(): kotlin.String?
public final override /*1*/ /*fake_override*/ fun test5(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
}
public abstract class B</*0*/ T : B<T>> {
public constructor B</*0*/ T : B<T>>()
protected abstract val thisBuilder: T
private final val x: kotlin.String? = null
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test6(/*0*/ obj: kotlin.Any?): T
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}