From a5c48576d5c275b32f40d21155500026a27f9fca Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Fri, 5 Aug 2022 19:25:30 +0200 Subject: [PATCH] [renderer] render presentable unresolved type with 'presentableUnresolvedTypes' option ^KT-49643 Fixed --- .../kotlin/renderer/DescriptorRendererImpl.kt | 7 ++++--- .../jetbrains/kotlin/types/error/ErrorUtils.kt | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 02127a318cb..b30176ee904 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -242,15 +242,16 @@ internal class DescriptorRendererImpl( when { type.isError -> { if (isUnresolvedType(type) && presentableUnresolvedTypes) { - append(type.debugMessage) + append(renderError(ErrorUtils.unresolvedTypeAsItIs(type))) } else { if (type is ErrorType && !informativeErrorType) { append(type.debugMessage) } else { append(type.constructor.toString()) // Debug name of an error type is more informative } + + append(renderTypeArguments(type.arguments)) } - append(renderTypeArguments(type.arguments)) } type is StubTypeForBuilderInference -> append(type.originalTypeVariable.toString()) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorUtils.kt index b9f77d1610e..f0ee71e08c0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorUtils.kt @@ -5,10 +5,18 @@ package org.jetbrains.kotlin.types.error -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.TypeConstructor +import org.jetbrains.kotlin.types.TypeProjection +import org.jetbrains.kotlin.types.isError import org.jetbrains.kotlin.types.typeUtil.contains +import org.jetbrains.kotlin.types.typeUtil.isUnresolvedType +import org.jetbrains.kotlin.utils.addToStdlib.cast object ErrorUtils { val errorModule: ModuleDescriptor = ErrorModuleDescriptor @@ -99,4 +107,9 @@ object ErrorUtils { } fun containsUninferredTypeVariable(type: KotlinType): Boolean = type.contains(::isUninferredTypeVariable) + + fun unresolvedTypeAsItIs(type: KotlinType): String { + assert(isUnresolvedType(type)) + return type.constructor.cast().getParam(0) + } }