diff --git a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/KtFe10TypeSystemCommonBackendContextForTypeMapping.kt b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/KtFe10TypeSystemCommonBackendContextForTypeMapping.kt index efe80fe43df..c430ae3ee59 100644 --- a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/KtFe10TypeSystemCommonBackendContextForTypeMapping.kt +++ b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/KtFe10TypeSystemCommonBackendContextForTypeMapping.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.analysis.api.descriptors.utils +import org.jetbrains.kotlin.builtins.FAKE_CONTINUATION_CLASS_DESCRIPTOR import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.descriptors.* @@ -14,6 +15,7 @@ import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContext import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor +import org.jetbrains.kotlin.types.error.ErrorTypeConstructor import org.jetbrains.kotlin.types.error.ErrorTypeKind import org.jetbrains.kotlin.types.error.ErrorUtils import org.jetbrains.kotlin.types.model.KotlinTypeMarker @@ -75,6 +77,9 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping( } override fun TypeConstructorMarker.typeWithArguments(arguments: List): SimpleTypeMarker { + if (this is ErrorTypeConstructor) { + return ErrorUtils.createErrorType(kind, this, *formatParams) + } require(this is TypeConstructor) require(parameters.size == arguments.size) @@ -110,10 +115,10 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping( val continuationFqName = StandardClassIds.Continuation.asSingleFqName() val foundClasses = resolveSession.getTopLevelClassifierDescriptors(continuationFqName, NoLookupLocation.FROM_IDE) return foundClasses.firstOrNull()?.typeConstructor - ?: ErrorUtils.createErrorTypeConstructor(ErrorTypeKind.NOT_FOUND_FQNAME, continuationFqName.toString()) + ?: FAKE_CONTINUATION_CLASS_DESCRIPTOR.typeConstructor } override fun functionNTypeConstructor(n: Int): TypeConstructorMarker { - return builtIns.getKFunction(n).typeConstructor + return builtIns.getFunction(n).typeConstructor } } diff --git a/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.descriptors.txt b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.descriptors.txt new file mode 100644 index 00000000000..20efb1bcb0a --- /dev/null +++ b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.descriptors.txt @@ -0,0 +1,2 @@ +KtType: suspend (kotlin.Int) -> kotlin.Unit +PsiType: PsiType:Function2, ? extends Object> diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/suspendFunctionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/suspendFunctionTypes.kt index 0c4632f663d..31d030ab92a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/suspendFunctionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/suspendFunctionTypes.kt @@ -22,7 +22,10 @@ import org.jetbrains.kotlin.types.error.ErrorUtils import org.jetbrains.kotlin.types.typeUtil.asTypeProjection import org.jetbrains.kotlin.types.typeUtil.builtIns -private val FAKE_CONTINUATION_CLASS_DESCRIPTOR = +// Continuation interface is not a part of built-ins anymore, it has been moved to stdlib. +// While it must be somewhere in the dependencies, but here we don't have a reference to the module, +// and it's rather complicated to inject it by now, so we just use a fake class descriptor. +val FAKE_CONTINUATION_CLASS_DESCRIPTOR = MutableClassDescriptor( EmptyPackageFragmentDescriptor(ErrorUtils.errorModule, COROUTINES_PACKAGE_FQ_NAME), ClassKind.INTERFACE, /* isInner = */ false, /* isExternal = */ false, @@ -51,9 +54,6 @@ fun transformSuspendFunctionToRuntimeFunctionType(suspendFunType: KotlinType): S suspendFunType.getValueParameterTypesFromFunctionType().map(TypeProjection::getType) + KotlinTypeFactory.simpleType( TypeAttributes.Empty, - // Continuation interface is not a part of built-ins anymore, it has been moved to stdlib. - // While it must be somewhere in the dependencies, but here we don't have a reference to the module, - // and it's rather complicated to inject it by now, so we just use a fake class descriptor. FAKE_CONTINUATION_CLASS_DESCRIPTOR.typeConstructor, listOf(suspendFunType.getReturnTypeFromFunctionType().asTypeProjection()), nullable = false ), diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorTypeConstructor.kt index e022dc7f3d9..ee20e36ed30 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorTypeConstructor.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeRefinement import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner -class ErrorTypeConstructor(val kind: ErrorTypeKind, private vararg val formatParams: String) : TypeConstructor { +class ErrorTypeConstructor(val kind: ErrorTypeKind, vararg val formatParams: String) : TypeConstructor { private val debugText = ErrorEntity.ERROR_TYPE.debugText.format(kind.debugMessage.format(*formatParams)) fun getParam(i: Int): String = formatParams[i]