diff --git a/idea/idea-fir-fe10-binding/src/org/jetbrains/kotlin/idea/fir/fe10/KtSymbolBasedKotlinTypes.kt b/idea/idea-fir-fe10-binding/src/org/jetbrains/kotlin/idea/fir/fe10/KtSymbolBasedKotlinTypes.kt index be6b938e7ff..1a30efbc8d0 100644 --- a/idea/idea-fir-fe10-binding/src/org/jetbrains/kotlin/idea/fir/fe10/KtSymbolBasedKotlinTypes.kt +++ b/idea/idea-fir-fe10-binding/src/org/jetbrains/kotlin/idea/fir/fe10/KtSymbolBasedKotlinTypes.kt @@ -110,20 +110,30 @@ fun KtTypeArgument.toTypeProjection(context: FE10BindingContext): TypeProjection } fun KtType.toKotlinType(context: FE10BindingContext, annotations: Annotations = Annotations.EMPTY): UnwrappedType { - if (this is KtNonDenotableType) return toKotlinType(context, annotations) - - val typeConstructor = when (this) { + val typeConstructor: TypeConstructor = when (this) { is KtTypeParameterType -> KtSymbolBasedTypeParameterDescriptor(this.symbol, context).typeConstructor - is KtClassType -> when (val classLikeSymbol = classSymbol) { + is KtNonErrorClassType -> when (val classLikeSymbol = classSymbol) { is KtTypeAliasSymbol -> context.typeAliasImplementationPlanned() is KtNamedClassOrObjectSymbol -> KtSymbolBasedClassDescriptor(classLikeSymbol, context).typeConstructor is KtAnonymousObjectSymbol -> context.implementationPostponed() } - is KtErrorType -> ErrorUtils.createErrorTypeConstructorWithCustomDebugName(error) + is KtClassErrorType -> ErrorUtils.createErrorTypeConstructorWithCustomDebugName(error) + is KtFlexibleType -> { + return KotlinTypeFactory.flexibleType( + lowerBound.toKotlinType(context, annotations) as SimpleType, + upperBound.toKotlinType(context, annotations) as SimpleType + ) + } + + is KtIntersectionType -> { + // most likely it isn't correct and intersectTypes(List) should be used, + // but I don't think that we will have the real problem with that implementation + return IntersectionTypeConstructor(conjuncts.map { it.toKotlinType(context) }).createType() + } else -> error("Unexpected subclass: ${this.javaClass}") } - val ktTypeArguments = this.safeAs()?.typeArguments ?: emptyList() + val ktTypeArguments = this.safeAs()?.typeArguments ?: emptyList() val markedAsNullable = this.safeAs()?.nullability == KtTypeNullability.NULLABLE @@ -131,15 +141,4 @@ fun KtType.toKotlinType(context: FE10BindingContext, annotations: Annotations = annotations, typeConstructor, ktTypeArguments.map { it.toTypeProjection(context) }, markedAsNullable, MemberScopeForKtSymbolBasedDescriptors { this.asStringForDebugging() } ) -} - -fun KtNonDenotableType.toKotlinType(context: FE10BindingContext, annotations: Annotations = Annotations.EMPTY): UnwrappedType = - when (this) { - is KtFlexibleType -> KotlinTypeFactory.flexibleType( - lowerBound.toKotlinType(context, annotations) as SimpleType, - upperBound.toKotlinType(context, annotations) as SimpleType - ) - // most likely it isn't correct and intersectTypes(List) should be used, - // but I don't think that we will have the real problem with that implementation - is KtIntersectionType -> IntersectionTypeConstructor(conjuncts.map { it.toKotlinType(context) }).createType() - } \ No newline at end of file +} \ No newline at end of file diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirCallableCompletionContributor.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirCallableCompletionContributor.kt index c0a14212405..bdfb5578bf1 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirCallableCompletionContributor.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirCallableCompletionContributor.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.idea.frontend.api.scopes.KtCompositeScope import org.jetbrains.kotlin.idea.frontend.api.scopes.KtScope import org.jetbrains.kotlin.idea.frontend.api.symbols.* import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType +import org.jetbrains.kotlin.idea.frontend.api.types.KtNonErrorClassType import org.jetbrains.kotlin.idea.frontend.api.types.KtType import org.jetbrains.kotlin.psi.KtExpression @@ -169,7 +170,7 @@ internal class FirCallableCompletionContributor( private class TypeNamesProvider(private val indexHelper: IndexHelper) { fun KtAnalysisSession.findAllNames(type: KtType): Set { - if (type !is KtClassType) return emptySet() + if (type !is KtNonErrorClassType) return emptySet() val typeName = type.classId.shortClassName.let { if (it.isSpecial) return emptySet() diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirClassifierCompletionContributor.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirClassifierCompletionContributor.kt index 96a12467f98..1bb3958a1f6 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirClassifierCompletionContributor.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirClassifierCompletionContributor.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.* import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.idea.completion.contributors.helpers.FirClassifierProvider.getAvailableClassifiersCurrentScope +import org.jetbrains.kotlin.idea.frontend.api.types.KtNonErrorClassType internal open class FirClassifierCompletionContributor( basicContext: FirBasicCompletionContext, @@ -82,7 +83,7 @@ internal class FirAnnotationCompletionContributor( } } is KtTypeAliasSymbol -> { - val expendedClass = (classifierSymbol.expandedType as? KtClassType)?.classSymbol + val expendedClass = (classifierSymbol.expandedType as? KtNonErrorClassType)?.classSymbol expendedClass?.let { filterClassifiers(it) } == true } } diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirWhenWithSubjectConditionContributor.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirWhenWithSubjectConditionContributor.kt index ad740ffdd8f..7a649cd75e8 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirWhenWithSubjectConditionContributor.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/FirWhenWithSubjectConditionContributor.kt @@ -72,7 +72,7 @@ internal class FirWhenWithSubjectConditionContributor( } private fun KtAnalysisSession.getClassSymbol(subjectType: KtType): KtNamedClassOrObjectSymbol? { - val classType = subjectType as? KtClassType + val classType = subjectType as? KtNonErrorClassType return classType?.classSymbol as? KtNamedClassOrObjectSymbol } @@ -107,7 +107,7 @@ internal class FirWhenWithSubjectConditionContributor( return when (classifier) { is KtAnonymousObjectSymbol -> return false is KtNamedClassOrObjectSymbol -> !classifier.classKind.isObject - is KtTypeAliasSymbol -> (classifier.expandedType as? KtClassType)?.classSymbol?.let { isPrefixNeeded(it) } == true + is KtTypeAliasSymbol -> (classifier.expandedType as? KtNonErrorClassType)?.classSymbol?.let { isPrefixNeeded(it) } == true is KtTypeParameterSymbol -> true } } diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/helpers/FirSuperEntriesProvider.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/helpers/FirSuperEntriesProvider.kt index 9494e6a6d8d..b4f71f41654 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/helpers/FirSuperEntriesProvider.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/contributors/helpers/FirSuperEntriesProvider.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.idea.completion.lookups.shortenReferencesForFirCompl import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.symbols.KtNamedClassOrObjectSymbol import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType +import org.jetbrains.kotlin.idea.frontend.api.types.KtNonErrorClassType import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType @@ -23,7 +24,7 @@ internal object FirSuperEntriesProvider { val containingClass = context.getStrictParentOfType() ?: return emptyList() val containingClassSymbol = containingClass.getClassOrObjectSymbol() return containingClassSymbol.superTypes.mapNotNull { superType -> - val classType = superType.type as? KtClassType ?: return@mapNotNull null + val classType = superType.type as? KtNonErrorClassType ?: return@mapNotNull null classType.classSymbol as? KtNamedClassOrObjectSymbol } } diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeTypeQuickFixFactories.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeTypeQuickFixFactories.kt index 077f163a29c..86842ec39c2 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeTypeQuickFixFactories.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeTypeQuickFixFactories.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPropertySymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithMembers import org.jetbrains.kotlin.idea.frontend.api.symbols.psiSafe import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType +import org.jetbrains.kotlin.idea.frontend.api.types.KtNonErrorClassType import org.jetbrains.kotlin.idea.frontend.api.types.KtType import org.jetbrains.kotlin.idea.quickfix.ChangeTypeFixUtils import org.jetbrains.kotlin.name.Name @@ -134,7 +135,7 @@ object ChangeTypeQuickFixFactories { ?: return@diagnosticFixFactory emptyList() buildList> { add(entryWithWrongType withInput Input(TargetType.VARIABLE, createTypeInfo(diagnostic.destructingType))) - val classSymbol = (diagnostic.psi.getKtType() as? KtClassType)?.classSymbol as? KtSymbolWithMembers ?: return@buildList + val classSymbol = (diagnostic.psi.getKtType() as? KtNonErrorClassType)?.classSymbol as? KtSymbolWithMembers ?: return@buildList val componentFunction = classSymbol.getMemberScope() .getCallableSymbols { it == diagnostic.componentFunctionName } .firstOrNull()?.psi as? KtCallableDeclaration diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt index 81a8af85532..fcb2d9e89af 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt @@ -27,7 +27,7 @@ interface KtExpressionTypeProviderMixIn : KtAnalysisSessionMixIn { /** * Returns the expected [KtType] of this [PsiElement] if it is an expression. The returned value should not be a - * [org.jetbrains.kotlin.idea.frontend.api.types.KtErrorType]. + * [org.jetbrains.kotlin.idea.frontend.api.types.KtClassErrorType]. */ fun PsiElement.getExpectedType(): KtType? = analysisSession.expressionTypeProvider.getExpectedType(this) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeInfoProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeInfoProvider.kt index 0a1f8acdb9e..ea9530ea804 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeInfoProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeInfoProvider.kt @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.idea.frontend.api.components import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType -import org.jetbrains.kotlin.idea.frontend.api.types.KtType -import org.jetbrains.kotlin.idea.frontend.api.types.KtTypeNullability -import org.jetbrains.kotlin.idea.frontend.api.types.KtTypeWithNullability +import org.jetbrains.kotlin.idea.frontend.api.types.* import org.jetbrains.kotlin.name.ClassId abstract class KtTypeInfoProvider : KtAnalysisSessionComponent() { @@ -47,13 +44,13 @@ interface KtTypeInfoProviderMixIn : KtAnalysisSessionMixIn { val KtType.isUByte: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uByte) fun KtType.isClassTypeWithClassId(classId: ClassId): Boolean { - if (this !is KtClassType) return false + if (this !is KtNonErrorClassType) return false return this.classId == classId } val KtType.isPrimitive: Boolean get() { - if (this !is KtClassType) return false + if (this !is KtNonErrorClassType) return false return this.classId in DefaultTypeClassIds.PRIMITIVES } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/types/KtType.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/types/KtType.kt index 6a7ff0a9ac0..243481e8377 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/types/KtType.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/types/KtType.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.frontend.api.types -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.idea.frontend.api.KtTypeArgument import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassLikeSymbol @@ -13,7 +12,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name -interface KtType : ValidityTokenOwner { +sealed interface KtType : ValidityTokenOwner { fun asStringForDebugging(): String } @@ -21,25 +20,23 @@ interface KtTypeWithNullability : KtType { val nullability: KtTypeNullability } -enum class KtTypeNullability { - NULLABLE, NON_NULLABLE; +enum class KtTypeNullability(val isNullable: Boolean) { + NULLABLE(true), NON_NULLABLE(false); companion object { fun create(isNullable: Boolean) = if (isNullable) NULLABLE else NON_NULLABLE } } -sealed class KtDenotableType : KtType { - abstract fun asString(): String -} +sealed class KtClassType : KtType -sealed class KtClassType : KtDenotableType(), KtTypeWithNullability { +sealed class KtNonErrorClassType: KtClassType(), KtTypeWithNullability { abstract val classId: ClassId abstract val classSymbol: KtClassLikeSymbol abstract val typeArguments: List } -abstract class KtFunctionalType : KtClassType() { +abstract class KtFunctionalType : KtNonErrorClassType() { abstract val isSuspend: Boolean abstract val arity: Int abstract val receiverType: KtType? @@ -47,24 +44,22 @@ abstract class KtFunctionalType : KtClassType() { abstract val returnType: KtType } -abstract class KtUsualClassType : KtClassType() +abstract class KtUsualClassType : KtNonErrorClassType() -abstract class KtErrorType : KtType { +abstract class KtClassErrorType : KtClassType() { abstract val error: String } -abstract class KtTypeParameterType : KtDenotableType(), KtTypeWithNullability { +abstract class KtTypeParameterType : KtTypeWithNullability { abstract val name: Name abstract val symbol: KtTypeParameterSymbol } -sealed class KtNonDenotableType : KtType - -abstract class KtFlexibleType : KtNonDenotableType() { +abstract class KtFlexibleType : KtType { abstract val lowerBound: KtType abstract val upperBound: KtType } -abstract class KtIntersectionType : KtNonDenotableType() { +abstract class KtIntersectionType : KtType{ abstract val conjuncts: List } \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/firLightClassUtils.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/firLightClassUtils.kt index b4475bda0ae..120703161c7 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/firLightClassUtils.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/firLightClassUtils.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.frontend.api.tokens.hackyAllowRunningOnEdt import org.jetbrains.kotlin.idea.frontend.api.symbols.* import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.* import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType +import org.jetbrains.kotlin.idea.frontend.api.types.KtNonErrorClassType import org.jetbrains.kotlin.idea.frontend.api.types.KtType import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.FqName @@ -289,7 +290,7 @@ internal fun FirLightClassBase.createInheritanceList(forExtendsList: Boolean, su ) fun KtType.needToAddTypeIntoList(): Boolean { - if (this !is KtClassType) return false + if (this !is KtNonErrorClassType) return false // Do not add redundant "extends java.lang.Object" anywhere if (this.classId == StandardClassIds.Any) return false diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/firLightUtils.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/firLightUtils.kt index 01e0fbebe70..7d3949e082e 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/firLightUtils.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/firLightUtils.kt @@ -165,7 +165,7 @@ internal fun KtType.mapSupertype( kotlinCollectionAsIs: Boolean = false, annotations: List ): PsiClassType? { - if (this !is KtClassType) return null + if (this !is KtNonErrorClassType) return null require(this is KtFirType) val contextSymbol = classSymbol require(contextSymbol is KtFirSymbol<*>) @@ -313,7 +313,7 @@ internal fun KtType.getTypeNullability(context: KtSymbol, phase: FirResolvePhase internal val KtType.isUnit get() = isClassTypeWithClassId(DefaultTypeClassIds.UNIT) internal fun KtType.isClassTypeWithClassId(classId: ClassId): Boolean { - if (this !is KtClassType) return false + if (this !is KtNonErrorClassType) return false return this.classId == classId } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/parameters/FirLightTypeParameter.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/parameters/FirLightTypeParameter.kt index 1dd9fc7c963..7793cc48c5c 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/parameters/FirLightTypeParameter.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/parameters/FirLightTypeParameter.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.asJava.mapSupertype import org.jetbrains.kotlin.idea.frontend.api.isValid import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol import org.jetbrains.kotlin.idea.frontend.api.types.KtClassType +import org.jetbrains.kotlin.idea.frontend.api.types.KtNonErrorClassType import org.jetbrains.kotlin.psi.KtTypeParameter import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -63,7 +64,7 @@ internal class FirLightTypeParameter( ) typeParameterSymbol.upperBounds - .filterIsInstance() + .filterIsInstance() .filter { it.classId != StandardClassIds.Any } .mapNotNull { it.mapSupertype( diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtSymbolByFirBuilder.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtSymbolByFirBuilder.kt index 2cf74befecd..dd372526e53 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtSymbolByFirBuilder.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtSymbolByFirBuilder.kt @@ -316,7 +316,7 @@ internal class KtSymbolByFirBuilder private constructor( else KtFirUsualClassType(coneType, token, this@KtSymbolByFirBuilder) } is ConeTypeParameterType -> KtFirTypeParameterType(coneType, token, this@KtSymbolByFirBuilder) - is ConeClassErrorType -> KtFirErrorType(coneType, token) + is ConeClassErrorType -> KtFirClassErrorType(coneType, token) is ConeFlexibleType -> KtFirFlexibleType(coneType, token, this@KtSymbolByFirBuilder) is ConeIntersectionType -> KtFirIntersectionType(coneType, token, this@KtSymbolByFirBuilder) is ConeDefinitelyNotNullType -> buildKtType(coneType.original) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionTypeProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionTypeProvider.kt index 9f577929ed0..9bccd15d79a 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionTypeProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionTypeProvider.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.idea.frontend.api.components.KtExpressionTypeProvide import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.fir.utils.getReferencedElementType import org.jetbrains.kotlin.idea.frontend.api.tokens.ValidityToken -import org.jetbrains.kotlin.idea.frontend.api.types.KtErrorType +import org.jetbrains.kotlin.idea.frontend.api.types.KtClassErrorType import org.jetbrains.kotlin.idea.frontend.api.types.KtType import org.jetbrains.kotlin.idea.frontend.api.withValidityAssertion import org.jetbrains.kotlin.lexer.KtTokens @@ -51,7 +51,7 @@ internal class KtFirExpressionTypeProvider( ?: getExpectedTypeByVariableAssignment(expression) ?: getExpectedTypeByPropertyDeclaration(expression) ?: getExpectedTypeByFunctionExpressionBody(expression) - return expectedType.takeIf { it !is KtErrorType } + return expectedType.takeIf { it !is KtClassErrorType } } private fun getExpectedTypeOfFunctionParameter(expression: PsiElement): KtType? {