Introduce KSEnumEntryDeclarationDescriptorImpl.

So that enum entries in descriptor based classes can be reported
correctly.

Change-Id: I9aa2b8107e470c709b97414db161449b425b28a8
diff --git a/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSClassDeclarationDescriptorImpl.kt b/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSClassDeclarationDescriptorImpl.kt
index c957621..f91a259 100644
--- a/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSClassDeclarationDescriptorImpl.kt
+++ b/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSClassDeclarationDescriptorImpl.kt
@@ -8,6 +8,7 @@
 import org.jetbrains.kotlin.descriptors.*
 import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
 import org.jetbrains.kotlin.ksp.symbol.*
+import org.jetbrains.kotlin.ksp.symbol.impl.kotlin.KSEnumEntryDeclarationImpl
 import org.jetbrains.kotlin.ksp.symbol.impl.kotlin.KSNameImpl
 import org.jetbrains.kotlin.ksp.symbol.impl.kotlin.KSTypeImpl
 import org.jetbrains.kotlin.ksp.symbol.impl.replaceTypeArguments
@@ -110,9 +111,10 @@
                     is FunctionDescriptor -> KSFunctionDeclarationDescriptorImpl.getCached(
                         it
                     )
-                    is ClassDescriptor -> KSClassDeclarationDescriptorImpl.getCached(
-                        it
-                    )
+                    is ClassDescriptor -> when (it.kind) {
+                        org.jetbrains.kotlin.descriptors.ClassKind.ENUM_ENTRY -> KSEnumEntryDeclarationDescriptorImpl.getCached(it)
+                        else -> KSClassDeclarationDescriptorImpl.getCached(it)
+                    }
                     else -> throw IllegalStateException()
                 }
             }
diff --git a/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSEnumEntryDeclarationDescriptorImpl.kt b/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSEnumEntryDeclarationDescriptorImpl.kt
new file mode 100644
index 0000000..cede618
--- /dev/null
+++ b/plugins/ksp/src/org/jetbrains/kotlin/ksp/symbol/impl/binary/KSEnumEntryDeclarationDescriptorImpl.kt
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.ksp.symbol.impl.binary
+
+import org.jetbrains.kotlin.descriptors.ClassDescriptor
+import org.jetbrains.kotlin.ksp.symbol.*
+import org.jetbrains.kotlin.psi.KtClassOrObject
+
+class KSEnumEntryDeclarationDescriptorImpl(val descriptor: ClassDescriptor) : KSEnumEntryDeclaration,
+    KSClassDeclaration by KSClassDeclarationDescriptorImpl.getCached(descriptor) {
+    companion object {
+        val cache = mutableMapOf<ClassDescriptor, KSEnumEntryDeclarationDescriptorImpl>()
+        fun getCached(descriptor: ClassDescriptor) = cache.getOrPut(descriptor) { KSEnumEntryDeclarationDescriptorImpl(descriptor) }
+    }
+}