From 498ec27559c92ac15e35024f19811267fd665f70 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Fri, 8 Jul 2022 21:10:41 +0200 Subject: [PATCH] [light classes] ultraLightUtils: cleanup code ^KT-53097 --- .../kotlin/asJava/classes/ultraLightUtils.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/classes/ultraLightUtils.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/classes/ultraLightUtils.kt index 8d585c83941..cdd42fa3bc8 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/classes/ultraLightUtils.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/classes/ultraLightUtils.kt @@ -143,14 +143,15 @@ private fun buildTypeParameterList( } -internal fun KtDeclaration.getKotlinType(): KotlinType? { - val descriptor = resolve() - return when (descriptor) { - is ValueDescriptor -> descriptor.type - is CallableDescriptor -> if (descriptor is FunctionDescriptor && descriptor.isSuspend) - descriptor.module.builtIns.nullableAnyType else descriptor.returnType - else -> null - } +internal fun KtDeclaration.getKotlinType(): KotlinType? = when (val descriptor = resolve()) { + is ValueDescriptor -> descriptor.type + is CallableDescriptor -> + if (descriptor is FunctionDescriptor && descriptor.isSuspend) + descriptor.module.builtIns.nullableAnyType + else + descriptor.returnType + + else -> null } internal fun KtDeclaration.resolve() = LightClassGenerationSupport.getInstance(project).resolveToDescriptor(this) @@ -392,11 +393,12 @@ internal fun KtModifierListOwner.isHiddenByDeprecation(support: KtUltraLightSupp val annotations = annotationEntries.filter { annotation -> annotation.looksLikeDeprecated() } - if (annotations.isNotEmpty()) { // some candidates found + + return if (annotations.isNotEmpty()) { // some candidates found val deprecated = support.findAnnotation(this, StandardNames.FqNames.deprecated)?.second - return (deprecated?.argumentValue("level") as? EnumValue)?.enumEntryName?.asString() == "HIDDEN" + (deprecated?.argumentValue("level") as? EnumValue)?.enumEntryName?.asString() == "HIDDEN" } else { - return false + false } } @@ -506,6 +508,7 @@ private fun ConstantValue<*>.asStringForPsiLiteral(parent: PsiElement): String = "$canonicalText$arrayPart.class" } + is EnumValue -> "${enumClassId.asSingleFqName().asString()}.$enumEntryName" else -> when (value) { is Long -> "${value}L"