Prohibit local objects and enum classes
#KT-5402 Fixed
#KT-4838 Fixed
Resolve type of object inside local object as special, not supertype('Any').
Changed visibility of constructor of anonymous object to 'internal' to be able to resolve the following:
fun box(): String {
var foo = object {
val bar = object {
val baz = "ok"
}
}
return foo.bar.baz
}
The containing declaration of property initializers is constructor, so 'baz' was invisible inside private constructor.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun foo() {
|
||||
<!LOCAL_ENUM_NOT_ALLOWED!>enum class A<!> {
|
||||
FOO
|
||||
BAR
|
||||
}
|
||||
val foo = A.FOO
|
||||
val b = object {
|
||||
<!LOCAL_ENUM_NOT_ALLOWED!>enum class B<!> {}
|
||||
}
|
||||
class C {
|
||||
<!LOCAL_ENUM_NOT_ALLOWED!>enum class D<!> {}
|
||||
}
|
||||
val f = {
|
||||
<!LOCAL_ENUM_NOT_ALLOWED!>enum class E<!> {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user