[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.
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
ed188204b4
commit
09acea5548
@@ -3,6 +3,10 @@
|
||||
// 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
|
||||
@@ -12,6 +16,7 @@ enum class Foo {
|
||||
};
|
||||
|
||||
abstract fun foo(): String
|
||||
abstract fun bar(): String
|
||||
abstract var xxx: String
|
||||
}
|
||||
|
||||
@@ -25,6 +30,7 @@ fun box(): String {
|
||||
assertEquals(Foo.FOO.xxx, "xxx")
|
||||
assertEquals(Foo.FOO.toString(), "FOO")
|
||||
assertEquals(Foo.valueOf("FOO").toString(), "FOO")
|
||||
assertEquals(Foo.FOO.bar(), "bar")
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user