Files
kotlin-fork/compiler/testData/codegen/box/enum/enumEntryMembers.kt
T
Juan Chen 09acea5548 [FIR]: Set proper classId to enum entries
FirVisibilityChecker::isVisible checked if a private declaration can be
accessed at a use site by matching class ids of the private
declaration's owner with the use site's containing class
declarations. When the private declaration is defined in an enum
entry and used in the same entry, its owner class id has the enum
entry name, but the use site is in an FirAnonymousObject, which has
"anonymous" as the class id. This causes visibility check to fail.

This PR fixes owner class ids of declarations defined in enum entries
to be the same as normal anonymous objects.
2020-10-15 14:46:22 +03:00

37 lines
798 B
Kotlin
Vendored

// WITH_RUNTIME
// MODULE: lib
// FILE: lib.kt
enum class Foo {
FOO() {
// Test for KT-42351
private fun privateBar() = "bar"
override fun bar(): String = privateBar()
override fun foo() = "foo"
override var xxx: String
get() = "xxx"
set(value: String) {
}
};
abstract fun foo(): String
abstract fun bar(): String
abstract var xxx: String
}
// MODULE: main(lib)
// FILE: main.kt
import kotlin.test.assertEquals
fun box(): String {
assertEquals(Foo.FOO.foo(), "foo")
Foo.FOO.xxx = "zzzz"
assertEquals(Foo.FOO.xxx, "xxx")
assertEquals(Foo.FOO.toString(), "FOO")
assertEquals(Foo.valueOf("FOO").toString(), "FOO")
assertEquals(Foo.FOO.bar(), "bar")
return "OK"
}