Add a warning for name shadowing case with Enum.entries

^KT-53153
This commit is contained in:
Mikhail Zarechenskiy
2023-01-02 15:40:21 +01:00
committed by Space Team
parent c70a1b1884
commit cf4b415a20
10 changed files with 179 additions and 1 deletions
@@ -0,0 +1,39 @@
// !LANGUAGE: -EnumEntries
package pckg
val entries = "E"
enum class E {
;
fun foo() {
<!DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM!>entries<!>
pckg.entries
}
}
class A {
enum class E {
;
class B {
fun foo() {
<!DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM!>entries<!>
pckg.entries
}
}
class C {
val entries = 0
fun foo() {
// technically, this warning is incorrect but I believe it's OK to report anyway
// first, logic in the compiler will be complicated if we'll try to avoid reporting warnings here
// second, this code smells, it'd be better to use qualifiers here anyway
<!DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM!>entries<!>
this.entries
}
}
}
}