Preserve synthetic enum methods in stub-based 'ClsClassImpl'

'ClsClassImpl' instances created by the platform contain synthetic
enum methods (added by 'ClassInnerStuffCache.calcMethods()'). Such
convention is common in IntelliJ (see KT-36095 and
'9a8b345adaded83fe13980a28db5d9f9acc7450d' in the IntelliJ repository).

This commit makes Kotlin's stub-based classes consistent with the
convention. Instead, a filter is added in place of 'ClsClassImpl' usage.

See also the following commits:
- 7c86911f44
- 43468c6d55
This commit is contained in:
Yan Zhulanow
2022-03-04 18:14:41 +09:00
parent fa4dadf9b7
commit c334a44e02
3 changed files with 9 additions and 33 deletions
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.analyzer.KotlinModificationTrackerService
import org.jetbrains.kotlin.asJava.classes.KotlinClassInnerStuffCache
import org.jetbrains.kotlin.asJava.classes.LightClassesLazyCreator
import org.jetbrains.kotlin.asJava.classes.lazyPub
import org.jetbrains.kotlin.asJava.isSyntheticValuesOrValueOfMethod
import org.jetbrains.kotlin.load.java.structure.LightClassOriginKind
import org.jetbrains.kotlin.psi.KtClassOrObject
@@ -155,7 +156,8 @@ open class KtLightClassForDecompiledDeclaration(
private val _methods: MutableList<PsiMethod> by lazyPub {
mutableListOf<PsiMethod>().also {
clsDelegate.methods.mapTo(it) { psiMethod ->
clsDelegate.methods.mapNotNullTo(it) { psiMethod ->
if (isSyntheticValuesOrValueOfMethod(psiMethod)) return@mapNotNullTo null
KtLightMethodForDecompiledDeclaration(
funDelegate = psiMethod,
funParent = this,