FIR: Fix case when smartcast receiver is used for call to private method
^KT-54432 Fixed
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
open class Base {
|
||||
fun foo(): String {
|
||||
return when (this) {
|
||||
is Derived -> baz()
|
||||
else -> "fail 1"
|
||||
}
|
||||
}
|
||||
|
||||
private fun baz(): String = "OK"
|
||||
}
|
||||
|
||||
class Derived : Base()
|
||||
|
||||
fun box(): String {
|
||||
return Derived().foo()
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
abstract class Base {
|
||||
fun foo(): String {
|
||||
return when (this) {
|
||||
is Derived -> baz()
|
||||
else -> "fail 1"
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun bar(): String
|
||||
|
||||
private fun Derived.baz(): String = bar() + k
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
override fun bar(): String = "O"
|
||||
val k: String get() = "K"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Derived().foo()
|
||||
}
|
||||
compiler/testData/diagnostics/tests/visibility/invisiblePrivateThroughSubClassDoubleSmartCast.fir.kt
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// SKIP_TXT
|
||||
// ISSUE: KT-52543
|
||||
|
||||
abstract class A {
|
||||
fun foo(a: Any) {
|
||||
if (a is A) {
|
||||
a.prv()
|
||||
if (a is B) {
|
||||
a.<!INVISIBLE_REFERENCE!>prv<!>()
|
||||
}
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
a.<!INVISIBLE_REFERENCE!>prv<!>()
|
||||
if (<!USELESS_IS_CHECK!>a is A<!>) {
|
||||
a.<!INVISIBLE_REFERENCE!>prv<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun prv() {}
|
||||
}
|
||||
|
||||
|
||||
open class B : A()
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// SKIP_TXT
|
||||
// ISSUE: KT-52543
|
||||
|
||||
abstract class A {
|
||||
fun foo(a: Any) {
|
||||
if (a is A) {
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.prv()
|
||||
if (a is B) {
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.prv()
|
||||
}
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.<!INVISIBLE_MEMBER!>prv<!>()
|
||||
if (<!USELESS_IS_CHECK!>a is A<!>) {
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.<!INVISIBLE_MEMBER!>prv<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun prv() {}
|
||||
}
|
||||
|
||||
|
||||
open class B : A()
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
|
||||
abstract class A {
|
||||
fun foo(a: A) {
|
||||
a.prv()
|
||||
if (a is B) {
|
||||
a.prv()
|
||||
}
|
||||
}
|
||||
|
||||
private fun prv() {}
|
||||
}
|
||||
|
||||
abstract class B : A()
|
||||
Reference in New Issue
Block a user