diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/classes/companionObject.kt b/compiler/testData/codegen/boxWithStdlib/reflection/classes/companionObject.kt index 097a2b52afa..fe985437cdb 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/classes/companionObject.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/classes/companionObject.kt @@ -5,6 +5,11 @@ class A { companion object C } +enum class E { + ENTRY; + companion object {} +} + fun box(): String { val obj = A::class.companionObject assertNotNull(obj) @@ -16,5 +21,7 @@ fun box(): String { assertNull(A.C::class.companionObject) assertNull(A.C::class.companionObjectInstance) + assertEquals(E.Companion, E::class.companionObjectInstance) + return "OK" } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index 714854859dd..e8bd4169cf7 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -120,7 +120,8 @@ internal class KClassImpl(override val jClass: Class) : KDeclaration } override val nestedClasses: Collection> - get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().map { nestedClass -> + get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().filterNot(DescriptorUtils::isEnumEntry).map { + nestedClass -> val source = (nestedClass as DeclarationDescriptorWithSource).source when (source) { is KotlinJvmBinarySourceElement ->