K1: introduce smartcast deprecation for a public API property in invisible class

#KT-56511 Fixed
Related to KT-57290
This commit is contained in:
Mikhail Glukhikh
2023-03-13 13:44:24 +01:00
committed by Space Team
parent 0b31e5ad63
commit 41c868445c
7 changed files with 61 additions and 16 deletions
@@ -0,0 +1,10 @@
// -- Module: <m1> --
// -- Module: <m2> --
/B.kt:13:13: warning: smart cast to 'String' is deprecated, because 'x' is a property declared in base class from different module inherited in non-public API class
x.length
^
/B.kt:22:9: warning: smart cast to 'String' is deprecated, because 'i.x' is a property declared in base class from different module inherited in non-public API class
i.x.length
^
@@ -1,3 +1,4 @@
// RENDER_DIAGNOSTICS_FULL_TEXT
// MODULE: m1
// FILE: A.kt
@@ -13,3 +14,11 @@ private class Derived : Base("123") {
}
}
}
internal class Internal : Base("456")
internal fun bar(i: Internal) {
if (i.x is String) {
i.x.length
}
}
@@ -1,3 +1,4 @@
// RENDER_DIAGNOSTICS_FULL_TEXT
// MODULE: m1
// FILE: A.kt
@@ -9,7 +10,15 @@ open class Base(val x: Any)
private class Derived : Base("123") {
fun foo() {
if (x is String) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
<!DEBUG_INFO_SMARTCAST, DEPRECATED_SMARTCAST!>x<!>.length
}
}
}
internal class Internal : Base("456")
internal fun bar(i: Internal) {
if (i.x is String) {
<!DEBUG_INFO_SMARTCAST, DEPRECATED_SMARTCAST!>i.x<!>.length
}
}