mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-18 08:31:38 +00:00
Prohibit accessing nested classes/objects of class object using class literal
The fqname of class should be clear from code Example: can't shorten A.Default.B.Default.C to A.B.C Also fixes problem when nested class of enum class could be accessed via enum entry
This commit is contained in:
@@ -13,17 +13,17 @@ class A {
|
||||
|
||||
fun foo(x : A.Default.Season) : String {
|
||||
return when (x) {
|
||||
A.Season.WINTER -> "winter"
|
||||
A.Season.SPRING -> "spring"
|
||||
A.Season.SUMMER -> "summer"
|
||||
A.Default.Season.WINTER -> "winter"
|
||||
A.Default.Season.SPRING -> "spring"
|
||||
A.Default.Season.SUMMER -> "summer"
|
||||
else -> "other"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
assertEquals("winter", foo(A.Season.WINTER))
|
||||
assertEquals("spring", foo(A.Season.SPRING))
|
||||
assertEquals("summer", foo(A.Season.SUMMER))
|
||||
assertEquals("other", foo(A.Season.AUTUMN))
|
||||
assertEquals("winter", foo(A.Default.Season.WINTER))
|
||||
assertEquals("spring", foo(A.Default.Season.SPRING))
|
||||
assertEquals("summer", foo(A.Default.Season.SUMMER))
|
||||
assertEquals("other", foo(A.Default.Season.AUTUMN))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user