[FIR] Rename ConeClassErrorType to ConeErrorType, drop ConeKotlinErrorType alias
This commit is contained in:
committed by
teamcity
parent
9c6292db6f
commit
0bd3e8f418
+1
-1
@@ -431,7 +431,7 @@ internal class KtSymbolByFirBuilder private constructor(
|
||||
else KtFirUsualClassType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
}
|
||||
is ConeTypeParameterType -> KtFirTypeParameterType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
is ConeClassErrorType -> KtFirClassErrorType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
is ConeErrorType -> KtFirClassErrorType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
is ConeFlexibleType -> KtFirFlexibleType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
is ConeIntersectionType -> KtFirIntersectionType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
is ConeDefinitelyNotNullType -> KtFirDefinitelyNotNullType(coneType, token, this@KtSymbolByFirBuilder)
|
||||
|
||||
+2
-2
@@ -179,9 +179,9 @@ internal fun ConeKotlinType.asPsiType(
|
||||
): PsiType? {
|
||||
val correctedType = simplifyType(session, useSitePosition)
|
||||
|
||||
if (correctedType is ConeClassErrorType || correctedType !is SimpleTypeMarker) return null
|
||||
if (correctedType is ConeErrorType || correctedType !is SimpleTypeMarker) return null
|
||||
|
||||
if (correctedType.typeArguments.any { it is ConeClassErrorType }) return null
|
||||
if (correctedType.typeArguments.any { it is ConeErrorType }) return null
|
||||
|
||||
val signatureWriter = BothSignatureWriter(BothSignatureWriter.Mode.SKIP_CHECKS)
|
||||
|
||||
|
||||
+1
-1
@@ -355,7 +355,7 @@ private class ElementsToShortenCollector(
|
||||
val ConeKotlinType.candidateClassId: ClassId?
|
||||
get() {
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> when (val diagnostic = this.diagnostic) {
|
||||
is ConeErrorType -> when (val diagnostic = this.diagnostic) {
|
||||
// Tolerate code that misses type parameters while shortening it.
|
||||
is ConeUnmatchedTypeArgumentsError -> diagnostic.symbol.classId
|
||||
else -> null
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedSymbolError
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.typeContext
|
||||
|
||||
@@ -33,7 +33,7 @@ internal class KtFirTypeCreator(
|
||||
val lookupTag = when (builder) {
|
||||
is KtClassTypeBuilder.ByClassId -> {
|
||||
val classSymbol = rootModuleSession.symbolProvider.getClassLikeSymbolByClassId(builder.classId)
|
||||
?: return ConeClassErrorType(ConeUnresolvedSymbolError(builder.classId)).asKtType() as KtClassType
|
||||
?: return ConeErrorType(ConeUnresolvedSymbolError(builder.classId)).asKtType() as KtClassType
|
||||
classSymbol.toLookupTag()
|
||||
}
|
||||
is KtClassTypeBuilder.BySymbol -> {
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ internal class KtFirTypeProvider(
|
||||
ConeDefinitelyNotNullType.create(it, analysisSession.rootModuleSession.typeContext) ?: it
|
||||
}
|
||||
is ConeIntersectionType -> intersectedTypes.asSequence().flatMap { it.getDirectSuperTypes(shouldApproximate) }
|
||||
is ConeClassErrorType -> emptySequence()
|
||||
is ConeErrorType -> emptySequence()
|
||||
is ConeLookupTagBasedType -> getSubstitutedSuperTypes(shouldApproximate)
|
||||
else -> emptySequence()
|
||||
}.distinct()
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ internal object FirCompileTimeConstantEvaluator {
|
||||
|
||||
private fun ConeKotlinType.toConstantValueKind(): ConstantValueKind<*>? =
|
||||
when (this) {
|
||||
is ConeKotlinErrorType -> null
|
||||
is ConeErrorType -> null
|
||||
is ConeLookupTagBasedType -> lookupTag.name.asString().toConstantValueKind()
|
||||
is ConeFlexibleType -> upperBound.toConstantValueKind()
|
||||
is ConeCapturedType -> lowerType?.toConstantValueKind() ?: constructor.supertypes!!.first().toConstantValueKind()
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ internal class ConeTypeIdeRenderer(
|
||||
|
||||
fun renderType(type: ConeTypeProjection): String = buildString {
|
||||
when (type) {
|
||||
is ConeKotlinErrorType -> {
|
||||
is ConeErrorType -> {
|
||||
renderErrorType(type)
|
||||
}
|
||||
//is Dynamic??? -> append("dynamic")
|
||||
@@ -90,7 +90,7 @@ internal class ConeTypeIdeRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun StringBuilder.renderErrorType(type: ConeKotlinErrorType) {
|
||||
private fun StringBuilder.renderErrorType(type: ConeErrorType) {
|
||||
val diagnostic = type.diagnostic
|
||||
if (options.renderUnresolvedTypeAsResolved && diagnostic is ConeUnresolvedError) {
|
||||
val qualifierRendered = diagnostic.qualifier?.let { FqName(it).render() }.orEmpty()
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ internal class KtFirFunctionalType(
|
||||
}
|
||||
|
||||
internal class KtFirClassErrorType(
|
||||
override val coneType: ConeClassErrorType,
|
||||
override val coneType: ConeErrorType,
|
||||
override val token: ValidityToken,
|
||||
private val builder: KtSymbolByFirBuilder,
|
||||
) : KtClassErrorType(), KtFirType {
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
@@ -56,7 +56,7 @@ internal fun FirNamedReference.getReferencedElementType(): ConeKotlinType {
|
||||
else -> error("Unexpected ${this::class}")
|
||||
}
|
||||
val firCallableDeclaration = symbols.singleOrNull()?.fir as? FirCallableDeclaration
|
||||
?: return ConeClassErrorType(ConeUnresolvedNameError(name))
|
||||
?: return ConeErrorType(ConeUnresolvedNameError(name))
|
||||
|
||||
return firCallableDeclaration.symbol.resolvedReturnType
|
||||
}
|
||||
@@ -95,4 +95,4 @@ internal fun FirExpression.asKtInitializerValue(): KtInitializerValue {
|
||||
null -> KtNonConstantInitializerValue(ktExpression)
|
||||
else -> KtConstantInitializerValue(evaluated, ktExpression)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -242,7 +242,7 @@ object ConeTypeCompatibilityChecker {
|
||||
private fun ConeKotlinType?.collectUpperBounds(): Set<ConeClassLikeType> {
|
||||
if (this == null) return emptySet()
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> emptySet() // Ignore error types
|
||||
is ConeErrorType -> emptySet() // Ignore error types
|
||||
is ConeLookupTagBasedType -> when (this) {
|
||||
is ConeClassLikeType -> setOf(this)
|
||||
is ConeTypeVariableType -> {
|
||||
@@ -267,7 +267,7 @@ object ConeTypeCompatibilityChecker {
|
||||
private fun ConeKotlinType?.collectLowerBounds(): Set<ConeClassLikeType> {
|
||||
if (this == null) return emptySet()
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> emptySet() // Ignore error types
|
||||
is ConeErrorType -> emptySet() // Ignore error types
|
||||
is ConeLookupTagBasedType -> when (this) {
|
||||
is ConeClassLikeType -> setOf(this)
|
||||
is ConeTypeVariableType -> emptySet()
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ internal fun checkConstantArguments(
|
||||
?.typeRef
|
||||
?.coneType
|
||||
|
||||
if (coneType is ConeClassErrorType)
|
||||
if (coneType is ConeErrorType)
|
||||
return ConstantArgumentKind.NOT_CONST
|
||||
|
||||
while (coneType?.classId == StandardClassIds.Array)
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ interface FirDeclarationPresenter {
|
||||
appendRepresentation(it.original)
|
||||
append(it.nullability.suffix)
|
||||
}
|
||||
is ConeClassErrorType -> {
|
||||
is ConeErrorType -> {
|
||||
append("ERROR(")
|
||||
append(it.diagnostic.reason)
|
||||
append(')')
|
||||
|
||||
@@ -616,7 +616,7 @@ fun checkTypeMismatch(
|
||||
internal fun checkCondition(condition: FirExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val coneType = condition.typeRef.coneTypeSafe<ConeKotlinType>()?.lowerBoundIfFlexible()
|
||||
if (coneType != null &&
|
||||
coneType !is ConeKotlinErrorType &&
|
||||
coneType !is ConeErrorType &&
|
||||
!coneType.isSubtypeOf(context.session.typeContext, context.session.builtinTypes.booleanType.type)
|
||||
) {
|
||||
reporter.reportOn(
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isConst
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
|
||||
@@ -57,7 +57,7 @@ object FirConstPropertyChecker : FirPropertyChecker() {
|
||||
}
|
||||
|
||||
val type = declaration.returnTypeRef.coneType.fullyExpandedType(context.session)
|
||||
if ((type !is ConeClassErrorType) && !type.canBeUsedForConstVal()) {
|
||||
if ((type !is ConeErrorType) && !type.canBeUsedForConstVal()) {
|
||||
reporter.reportOn(declaration.source, FirErrors.TYPE_CANT_BE_USED_FOR_CONST_VAL, declaration.returnTypeRef.coneType, context)
|
||||
return
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateErr
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableWrongReceiver
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.render
|
||||
import org.jetbrains.kotlin.fir.types.typeContext
|
||||
@@ -39,7 +39,7 @@ object FirDelegatedPropertyChecker : FirPropertyChecker() {
|
||||
// TODO: Also suppress delegate issue if type inference failed. For example, in
|
||||
// compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.fir.kt, no delegate issues are
|
||||
// reported due to the inference issue.
|
||||
if (delegateType is ConeKotlinErrorType) {
|
||||
if (delegateType is ConeErrorType) {
|
||||
val delegateSource = delegate.source
|
||||
// Implicit recursion type is not reported since the type ref does not have a real source.
|
||||
if (delegateSource != null && (delegateType.diagnostic as? ConeSimpleDiagnostic)?.kind == DiagnosticKind.RecursionInImplicitTypes) {
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ object FirDestructuringDeclarationChecker : FirPropertyChecker() {
|
||||
}
|
||||
is ConeConstraintSystemHasContradiction -> {
|
||||
val componentType = componentCall.typeRef.coneType
|
||||
if (componentType is ConeKotlinErrorType) {
|
||||
if (componentType is ConeErrorType) {
|
||||
// There will be other errors on this error type.
|
||||
return
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenProperties
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.delegatedWrapperData
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.typeContext
|
||||
@@ -126,7 +126,7 @@ object FirImplementationMismatchChecker : FirClassChecker() {
|
||||
it to context.returnTypeCalculator.tryCalculateReturnType(it).coneType
|
||||
}
|
||||
|
||||
if (withTypes.any { it.second is ConeKotlinErrorType }) return
|
||||
if (withTypes.any { it.second is ConeErrorType }) return
|
||||
|
||||
var delegation: FirCallableSymbol<*>? = null
|
||||
val implementations = mutableListOf<FirCallableSymbol<*>>()
|
||||
|
||||
+2
-2
@@ -50,11 +50,11 @@ object FirKClassWithIncorrectTypeArgumentChecker : FirCallableDeclarationChecker
|
||||
argumentType.typeParameterFromError?.let { typeParameterSymbol ->
|
||||
return typeParameterSymbol.toConeType().isNullableType()
|
||||
}
|
||||
return argumentType is ConeKotlinErrorType || argumentType.isNullableType()
|
||||
return argumentType is ConeErrorType || argumentType.isNullableType()
|
||||
}
|
||||
}
|
||||
|
||||
private val ConeKotlinType.typeParameterFromError: FirTypeParameterSymbol?
|
||||
get() = ((this as? ConeKotlinErrorType)?.diagnostic as? ConeTypeParameterInQualifiedAccess)?.symbol
|
||||
get() = ((this as? ConeErrorType)?.diagnostic as? ConeTypeParameterInQualifiedAccess)?.symbol
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ object FirOverrideChecker : FirClassChecker() {
|
||||
val overridingReturnType = resolvedReturnTypeRef.coneType
|
||||
|
||||
// Don't report *_ON_OVERRIDE diagnostics according to an error return type. That should be reported separately.
|
||||
if (overridingReturnType is ConeKotlinErrorType) {
|
||||
if (overridingReturnType is ConeErrorType) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.canHaveAbstractDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isAbstract
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isOpen
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.isUnit
|
||||
|
||||
@@ -49,7 +49,7 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
return
|
||||
}
|
||||
val getterReturnType = getterReturnTypeRef.coneType
|
||||
if (propertyType is ConeClassErrorType || getterReturnType is ConeClassErrorType) {
|
||||
if (propertyType is ConeErrorType || getterReturnType is ConeErrorType) {
|
||||
return
|
||||
}
|
||||
if (getterReturnType != property.returnTypeRef.coneType) {
|
||||
@@ -94,7 +94,7 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
}
|
||||
val valueSetterType = valueSetterParameter.returnTypeRef.coneType
|
||||
val valueSetterTypeSource = valueSetterParameter.returnTypeRef.source
|
||||
if (propertyType is ConeClassErrorType || valueSetterType is ConeClassErrorType) {
|
||||
if (propertyType is ConeErrorType || valueSetterType is ConeErrorType) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
}
|
||||
|
||||
val setterReturnType = setter.returnTypeRef.coneType
|
||||
if (propertyType is ConeClassErrorType || valueSetterType is ConeClassErrorType) {
|
||||
if (propertyType is ConeErrorType || valueSetterType is ConeErrorType) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.classId
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
|
||||
object FirThrowableSubclassChecker : FirClassChecker() {
|
||||
override fun check(declaration: FirClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
@@ -37,7 +37,7 @@ object FirThrowableSubclassChecker : FirClassChecker() {
|
||||
}
|
||||
|
||||
private fun FirClass.hasThrowableSupertype(context: CheckerContext) =
|
||||
superConeTypes.any { it !is ConeClassErrorType && it.isSubtypeOfThrowable(context.session) }
|
||||
superConeTypes.any { it !is ConeErrorType && it.isSubtypeOfThrowable(context.session) }
|
||||
|
||||
private fun FirClass.hasGenericOuterDeclaration(context: CheckerContext): Boolean {
|
||||
if (!classId.isLocal) return false
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ object FirTopLevelTypeAliasChecker : FirTypeAliasChecker() {
|
||||
val fullyExpandedType = expandedTypeRef.coneType.fullyExpandedType(context.session)
|
||||
|
||||
if (containsTypeParameter(fullyExpandedType) ||
|
||||
fullyExpandedType is ConeClassErrorType && fullyExpandedType.diagnostic is ConeUnsupportedDynamicType
|
||||
fullyExpandedType is ConeErrorType && fullyExpandedType.diagnostic is ConeUnsupportedDynamicType
|
||||
) {
|
||||
reporter.reportOn(
|
||||
declaration.expandedTypeRef.source,
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ object FirEqualityCompatibilityChecker : FirEqualityOperatorCallChecker() {
|
||||
lType.isNullableNothing -> rType
|
||||
else -> return
|
||||
}
|
||||
if (type is ConeKotlinErrorType) return
|
||||
if (type is ConeErrorType) return
|
||||
val isPositiveCompare = expression.operation == FirOperation.EQ || expression.operation == FirOperation.IDENTITY
|
||||
val compareResult = with(context.session.typeContext) {
|
||||
when {
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirUserTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
@@ -26,9 +26,9 @@ object FirSuperReferenceChecker : FirQualifiedAccessExpressionChecker() {
|
||||
val typeArgumentList = delegatedTypeRef.qualifier.firstOrNull()?.typeArgumentList ?: return
|
||||
val superType = superTypeRef.coneType
|
||||
|
||||
if (superType !is ConeKotlinErrorType &&
|
||||
if (superType !is ConeErrorType &&
|
||||
typeArgumentList.typeArguments.isNotEmpty() &&
|
||||
superType.typeArguments.all { it !is ConeKotlinErrorType }
|
||||
superType.typeArguments.all { it !is ConeErrorType }
|
||||
) {
|
||||
reporter.reportOn(typeArgumentList.source, FirErrors.TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER, context)
|
||||
}
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirElvisExpression
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.canBeNull
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.isNullLiteral
|
||||
@@ -20,10 +20,10 @@ object FirUselessElvisChecker : FirElvisExpressionChecker() {
|
||||
// If the overall expression is not resolved/completed, the corresponding error will be reported separately.
|
||||
// See [FirControlFlowStatementsResolveTransformer#transformElvisExpression],
|
||||
// where an error type is recorded as the expression's return type.
|
||||
if (expression.typeRef.coneType is ConeKotlinErrorType) return
|
||||
if (expression.typeRef.coneType is ConeErrorType) return
|
||||
|
||||
val lhsType = expression.lhs.typeRef.coneType
|
||||
if (lhsType is ConeKotlinErrorType) return
|
||||
if (lhsType is ConeErrorType) return
|
||||
if (!lhsType.canBeNull) {
|
||||
reporter.reportOn(expression.source, FirErrors.USELESS_ELVIS, lhsType, context)
|
||||
return
|
||||
|
||||
+2
-2
@@ -22,10 +22,10 @@ object FirUselessTypeOperationCallChecker : FirTypeOperatorCallChecker() {
|
||||
val arg = expression.argument
|
||||
|
||||
val candidateType = arg.typeRef.coneType.upperBoundIfFlexible().fullyExpandedType(context.session)
|
||||
if (candidateType is ConeKotlinErrorType) return
|
||||
if (candidateType is ConeErrorType) return
|
||||
|
||||
val targetType = expression.conversionTypeRef.coneType.fullyExpandedType(context.session)
|
||||
if (targetType is ConeKotlinErrorType) return
|
||||
if (targetType is ConeErrorType) return
|
||||
|
||||
// x as? Type <=> x as Type?
|
||||
val refinedTargetType =
|
||||
|
||||
+2
-2
@@ -177,7 +177,7 @@ abstract class AbstractDiagnosticCollectorVisitor(
|
||||
// as children in delegatedTypeRef. We should make sure those elements are only visited once, otherwise diagnostics will be
|
||||
// collected twice: once through resolvedTypeRef's children and another through resolvedTypeRef.delegatedTypeRef's children.
|
||||
val resolvedTypeRefType = resolvedTypeRef.type
|
||||
if (resolvedTypeRefType is ConeClassErrorType) {
|
||||
if (resolvedTypeRefType is ConeErrorType) {
|
||||
super.visitResolvedTypeRef(resolvedTypeRef, data)
|
||||
}
|
||||
if (resolvedTypeRef.source?.kind is KtFakeSourceElementKind) return
|
||||
@@ -185,7 +185,7 @@ abstract class AbstractDiagnosticCollectorVisitor(
|
||||
//the note about is just wrong
|
||||
//if we don't visit resolved type we can't make any diagnostics on them
|
||||
//so here we check resolvedTypeRef
|
||||
if (resolvedTypeRefType !is ConeClassErrorType) {
|
||||
if (resolvedTypeRefType !is ConeErrorType) {
|
||||
withAnnotationContainer(resolvedTypeRef) {
|
||||
checkElement(resolvedTypeRef)
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.render
|
||||
@@ -41,7 +41,7 @@ class ErrorNodeDiagnosticCollectorComponent(
|
||||
}
|
||||
|
||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: CheckerContext) {
|
||||
assert(resolvedTypeRef.type !is ConeKotlinErrorType) {
|
||||
assert(resolvedTypeRef.type !is ConeErrorType) {
|
||||
"Instead use FirErrorTypeRef for ${resolvedTypeRef.type.render()}"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,6 +28,6 @@ private class TypeVariableTypeRemovingSubstitutor(typeContext: ConeTypeContext)
|
||||
check(originalTypeParameter is ConeTypeParameterLookupTag)
|
||||
return ConeTypeParameterTypeImpl(originalTypeParameter, type.isNullable, type.attributes)
|
||||
}
|
||||
return ConeClassErrorType(ConeUnknownLambdaParameterTypeDiagnostic())
|
||||
return ConeErrorType(ConeUnknownLambdaParameterTypeDiagnostic())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ private fun ConeKotlinType.contains(predicate: (ConeKotlinType) -> Boolean, visi
|
||||
|
||||
fun ConeClassLikeType.withArguments(typeArguments: Array<out ConeTypeProjection>): ConeClassLikeType = when (this) {
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, typeArguments, isNullable, attributes)
|
||||
is ConeClassErrorType -> this
|
||||
is ConeErrorType -> this
|
||||
else -> error("Unknown cone type: ${this::class}")
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,9 @@ sealed class ConeKotlinType : ConeKotlinTypeProjection(), KotlinTypeMarker, Type
|
||||
|
||||
sealed class ConeSimpleKotlinType : ConeKotlinType(), SimpleTypeMarker
|
||||
|
||||
typealias ConeKotlinErrorType = ConeClassErrorType
|
||||
|
||||
class ConeClassLikeErrorLookupTag(override val classId: ClassId) : ConeClassLikeLookupTag()
|
||||
|
||||
class ConeClassErrorType(val diagnostic: ConeDiagnostic, val isUninferredParameter: Boolean = false) : ConeClassLikeType() {
|
||||
class ConeErrorType(val diagnostic: ConeDiagnostic, val isUninferredParameter: Boolean = false) : ConeClassLikeType() {
|
||||
override val lookupTag: ConeClassLikeLookupTag
|
||||
get() = ConeClassLikeErrorLookupTag(ClassId.fromString("<error>"))
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
fun ConeKotlinType.render(): String {
|
||||
val nullabilitySuffix = if (this !is ConeFlexibleType && this !is ConeClassErrorType) nullability.suffix else ""
|
||||
val nullabilitySuffix = if (this !is ConeFlexibleType && this !is ConeErrorType) nullability.suffix else ""
|
||||
return when (this) {
|
||||
is ConeTypeVariableType -> "${renderAttributes()}TypeVariable(${this.lookupTag.name})"
|
||||
is ConeDefinitelyNotNullType -> "${original.render()} & Any"
|
||||
is ConeClassErrorType -> "${renderAttributes()}ERROR CLASS: ${diagnostic.reason}"
|
||||
is ConeErrorType -> "${renderAttributes()}ERROR CLASS: ${diagnostic.reason}"
|
||||
is ConeCapturedType -> "${renderAttributes()}CapturedType(${constructor.projection.render()})"
|
||||
is ConeClassLikeType -> {
|
||||
buildString {
|
||||
|
||||
@@ -843,7 +843,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
|
||||
private fun FlowContent.generate(type: ConeKotlinType) {
|
||||
when (type) {
|
||||
is ConeClassErrorType -> error { +type.diagnostic.reason }
|
||||
is ConeErrorType -> error { +type.diagnostic.reason }
|
||||
is ConeClassLikeType -> return generate(type)
|
||||
is ConeTypeParameterType -> resolved {
|
||||
symbolRef(type.lookupTag.symbol) {
|
||||
|
||||
+3
-3
@@ -118,7 +118,7 @@ class FirTypeDeserializer(
|
||||
return ConeFlexibleType(lowerBound!!, upperBound!!)
|
||||
}
|
||||
|
||||
return simpleType(proto, attributes) ?: ConeKotlinErrorType(ConeSimpleDiagnostic("?!id:0", DiagnosticKind.DeserializationError))
|
||||
return simpleType(proto, attributes) ?: ConeErrorType(ConeSimpleDiagnostic("?!id:0", DiagnosticKind.DeserializationError))
|
||||
}
|
||||
|
||||
private fun typeParameterSymbol(typeParameterId: Int): ConeTypeParameterLookupTag? =
|
||||
@@ -211,7 +211,7 @@ class FirTypeDeserializer(
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
return result ?: ConeClassErrorType(
|
||||
return result ?: ConeErrorType(
|
||||
ConeSimpleDiagnostic(
|
||||
"Bad suspend function in metadata with constructor: $functionTypeConstructor",
|
||||
DiagnosticKind.DeserializationError
|
||||
@@ -240,7 +240,7 @@ class FirTypeDeserializer(
|
||||
|
||||
val variance = ProtoEnumFlags.variance(typeArgumentProto.projection)
|
||||
val type = typeArgumentProto.type(typeTable)
|
||||
?: return ConeKotlinErrorType(ConeSimpleDiagnostic("No type recorded", DiagnosticKind.DeserializationError))
|
||||
?: return ConeErrorType(ConeSimpleDiagnostic("No type recorded", DiagnosticKind.DeserializationError))
|
||||
val coneType = type(type)
|
||||
return coneType.toTypeProjection(variance)
|
||||
}
|
||||
|
||||
+1
-1
@@ -652,7 +652,7 @@ class FirElementSerializer private constructor(
|
||||
val builder = ProtoBuf.Type.newBuilder()
|
||||
when (type) {
|
||||
is ConeDefinitelyNotNullType -> return typeProto(type.original, toSuper, correspondingTypeRef, isDefinitelyNotNullType = true)
|
||||
is ConeKotlinErrorType -> {
|
||||
is ConeErrorType -> {
|
||||
extension.serializeErrorType(type, builder)
|
||||
return builder
|
||||
}
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.types.ConeFlexibleType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.serialization.MutableVersionRequirementTable
|
||||
@@ -83,7 +83,7 @@ abstract class FirSerializerExtension {
|
||||
open fun serializeTypeAlias(typeAlias: FirTypeAlias, proto: ProtoBuf.TypeAlias.Builder) {
|
||||
}
|
||||
|
||||
open fun serializeErrorType(type: ConeKotlinErrorType, builder: ProtoBuf.Type.Builder) {
|
||||
open fun serializeErrorType(type: ConeErrorType, builder: ProtoBuf.Type.Builder) {
|
||||
throw IllegalStateException("Cannot serialize error type: $type")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ internal class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(valu
|
||||
|
||||
companion object {
|
||||
fun create(argumentType: ConeKotlinType): ConstantValue<*>? {
|
||||
if (argumentType is ConeKotlinErrorType) return null
|
||||
if (argumentType is ConeErrorType) return null
|
||||
if (argumentType !is ConeClassLikeType) return null
|
||||
var type = argumentType
|
||||
var arrayDimensions = 0
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ class FirJvmSerializerExtension(
|
||||
(grandParent.classKind == ClassKind.INTERFACE || grandParent.classKind == ClassKind.ANNOTATION_CLASS)
|
||||
}
|
||||
|
||||
override fun serializeErrorType(type: ConeKotlinErrorType, builder: ProtoBuf.Type.Builder) {
|
||||
override fun serializeErrorType(type: ConeErrorType, builder: ProtoBuf.Type.Builder) {
|
||||
if (classBuilderMode === ClassBuilderMode.KAPT3) {
|
||||
builder.className = stringTable.getStringIndex(NON_EXISTENT_CLASS_NAME)
|
||||
return
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class FirMetadataSerializer(
|
||||
) : MetadataSerializer {
|
||||
private val approximator = object : AbstractTypeApproximator(session.typeContext, session.languageVersionSettings) {
|
||||
override fun createErrorType(debugName: String): SimpleTypeMarker {
|
||||
return ConeKotlinErrorType(ConeIntermediateDiagnostic(debugName))
|
||||
return ConeErrorType(ConeIntermediateDiagnostic(debugName))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class Fir2IrTypeConverter(
|
||||
addRawTypeAnnotation: Boolean = false
|
||||
): IrType {
|
||||
return when (this) {
|
||||
is ConeKotlinErrorType -> createErrorType()
|
||||
is ConeErrorType -> createErrorType()
|
||||
is ConeLookupTagBasedType -> {
|
||||
val typeAnnotations = mutableListOf<IrConstructorCall>()
|
||||
typeAnnotations += with(annotationGenerator) { annotations.toIrAnnotations() }
|
||||
|
||||
@@ -266,7 +266,7 @@ private fun ConeKotlinType.mapToCanonicalString(session: FirSession): String {
|
||||
|
||||
private fun ConeClassLikeType.mapToCanonicalString(session: FirSession): String {
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> ERROR_TYPE_STUB
|
||||
is ConeErrorType -> ERROR_TYPE_STUB
|
||||
else -> fullyExpandedType(session).mapToCanonicalNoExpansionString(session)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ internal fun FirTypeRef.toConeKotlinTypeProbablyFlexible(
|
||||
mode: FirJavaTypeConversionMode = FirJavaTypeConversionMode.DEFAULT
|
||||
): ConeKotlinType =
|
||||
(resolveIfJavaType(session, javaTypeParameterStack, mode) as? FirResolvedTypeRef)?.type
|
||||
?: ConeKotlinErrorType(ConeSimpleDiagnostic("Type reference in Java not resolved: ${this::class.java}", DiagnosticKind.Java))
|
||||
?: ConeErrorType(ConeSimpleDiagnostic("Type reference in Java not resolved: ${this::class.java}", DiagnosticKind.Java))
|
||||
|
||||
internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterStack: JavaTypeParameterStack): FirJavaTypeRef {
|
||||
return buildJavaTypeRef {
|
||||
@@ -202,7 +202,7 @@ private fun JavaClassifierType.toConeKotlinTypeForFlexibleBound(
|
||||
val classId = ClassId.topLevel(FqName(this.classifierQualifiedName))
|
||||
classId.constructClassLikeType(emptyArray(), isNullable = lowerBound != null, attributes)
|
||||
}
|
||||
else -> ConeKotlinErrorType(ConeSimpleDiagnostic("Unexpected classifier: $classifier", DiagnosticKind.Java))
|
||||
else -> ConeErrorType(ConeSimpleDiagnostic("Unexpected classifier: $classifier", DiagnosticKind.Java))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ private fun List<FirTypeParameterSymbol>.eraseToUpperBounds(session: FirSession)
|
||||
private fun FirTypeParameter.eraseToUpperBound(session: FirSession, cache: MutableMap<FirTypeParameter, ConeKotlinType>): ConeKotlinType {
|
||||
return cache.getOrPut(this) {
|
||||
// Mark to avoid loops.
|
||||
cache[this] = ConeKotlinErrorType(ConeIntermediateDiagnostic("self-recursive type parameter $name"))
|
||||
cache[this] = ConeErrorType(ConeIntermediateDiagnostic("self-recursive type parameter $name"))
|
||||
// We can assume that Java type parameter bounds are already converted.
|
||||
symbol.resolvedBounds.first().coneType.eraseAsUpperBound(session, cache)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ internal fun JavaAnnotationArgument.toFirExpression(
|
||||
typeRef = it
|
||||
buildResolvedTypeRef {
|
||||
type = it.coneTypeSafe<ConeKotlinType>()?.lowerBoundIfFlexible()?.arrayElementType()
|
||||
?: ConeClassErrorType(ConeSimpleDiagnostic("expected type is not array type"))
|
||||
?: ConeErrorType(ConeSimpleDiagnostic("expected type is not array type"))
|
||||
}
|
||||
}
|
||||
argumentList = buildArgumentList {
|
||||
|
||||
@@ -111,7 +111,7 @@ private fun StringBuilder.appendConeType(
|
||||
}
|
||||
|
||||
when (coneType) {
|
||||
is ConeClassErrorType -> Unit // TODO: just skipping it seems wrong
|
||||
is ConeErrorType -> Unit // TODO: just skipping it seems wrong
|
||||
is ConeClassLikeType -> {
|
||||
appendClassLikeType(coneType)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ inline fun FirFunctionCall.copyAsImplicitInvokeCall(
|
||||
fun FirTypeRef.resolvedTypeFromPrototype(
|
||||
type: ConeKotlinType
|
||||
): FirResolvedTypeRef {
|
||||
return if (type is ConeKotlinErrorType) {
|
||||
return if (type is ConeErrorType) {
|
||||
buildErrorTypeRef {
|
||||
source = this@resolvedTypeFromPrototype.source
|
||||
this.type = type
|
||||
|
||||
@@ -58,7 +58,7 @@ fun ConeKotlinType.scope(
|
||||
|
||||
private fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession, requiredPhase: FirResolvePhase): FirTypeScope? {
|
||||
return when (this) {
|
||||
is ConeKotlinErrorType -> null
|
||||
is ConeErrorType -> null
|
||||
is ConeClassLikeType -> {
|
||||
val fullyExpandedType = fullyExpandedType(useSiteSession)
|
||||
val fir = fullyExpandedType.lookupTag.toSymbol(useSiteSession)?.fir as? FirClass ?: return null
|
||||
|
||||
@@ -191,7 +191,7 @@ private fun FirClassifierSymbol<*>.collectSuperTypes(
|
||||
list += superClassTypes
|
||||
if (deep)
|
||||
superClassTypes.forEach {
|
||||
if (it !is ConeClassErrorType) {
|
||||
if (it !is ConeErrorType) {
|
||||
if (substituteSuperTypes) {
|
||||
val substitutedTypes = SmartList<ConeClassLikeType>()
|
||||
it.lookupTag.toSymbol(useSiteSession)?.collectSuperTypes(
|
||||
@@ -234,7 +234,7 @@ private fun FirClassifierSymbol<*>.collectSuperTypes(
|
||||
private fun ConeClassLikeType?.isClassBasedType(
|
||||
useSiteSession: FirSession
|
||||
): Boolean {
|
||||
if (this is ConeClassErrorType) return false
|
||||
if (this is ConeErrorType) return false
|
||||
val symbol = this?.lookupTag?.toSymbol(useSiteSession) as? FirClassSymbol ?: return false
|
||||
return when (symbol) {
|
||||
is FirAnonymousObjectSymbol -> true
|
||||
@@ -245,7 +245,7 @@ private fun ConeClassLikeType?.isClassBasedType(
|
||||
fun createSubstitutionForSupertype(superType: ConeLookupTagBasedType, session: FirSession): ConeSubstitutor {
|
||||
val klass = superType.lookupTag.toSymbol(session)?.fir as? FirRegularClass ?: return ConeSubstitutor.Empty
|
||||
val arguments = superType.typeArguments.map {
|
||||
it as? ConeKotlinType ?: ConeClassErrorType(ConeSimpleDiagnostic("illegal projection usage", DiagnosticKind.IllegalProjectionUsage))
|
||||
it as? ConeKotlinType ?: ConeErrorType(ConeSimpleDiagnostic("illegal projection usage", DiagnosticKind.IllegalProjectionUsage))
|
||||
}
|
||||
val mapping = klass.typeParameters.map { it.symbol }.zip(arguments).toMap()
|
||||
return ConeSubstitutorByMap(mapping, session)
|
||||
|
||||
@@ -129,7 +129,7 @@ private fun mapTypeAliasArguments(
|
||||
val mappedProjection = typeAliasMap[symbol] ?: return super.substituteArgument(projection, lookupTag, index)
|
||||
var mappedType = (mappedProjection as? ConeKotlinTypeProjection)?.type.updateNullabilityIfNeeded(type)
|
||||
mappedType = when (mappedType) {
|
||||
is ConeClassErrorType,
|
||||
is ConeErrorType,
|
||||
is ConeClassLikeTypeImpl,
|
||||
is ConeDefinitelyNotNullType,
|
||||
is ConeTypeParameterTypeImpl,
|
||||
|
||||
@@ -46,7 +46,7 @@ abstract class AbstractExplicitReceiverValue<E : FirExpression> : AbstractExplic
|
||||
override val type: ConeKotlinType
|
||||
// NB: safe cast is necessary here
|
||||
get() = explicitReceiver.typeRef.coneTypeSafe()
|
||||
?: ConeKotlinErrorType(ConeIntermediateDiagnostic("No type calculated for: ${explicitReceiver.renderWithType()}")) // TODO: assert here
|
||||
?: ConeErrorType(ConeIntermediateDiagnostic("No type calculated for: ${explicitReceiver.renderWithType()}")) // TODO: assert here
|
||||
|
||||
override val receiverExpression: FirExpression
|
||||
get() = explicitReceiver
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ abstract class AbstractConeSubstitutor(protected val typeContext: ConeTypeContex
|
||||
|
||||
private fun ConeKotlinType.substituteRecursive(): ConeKotlinType? {
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> return null
|
||||
is ConeErrorType -> return null
|
||||
is ConeClassLikeType -> this.substituteArguments()
|
||||
is ConeLookupTagBasedType -> return null
|
||||
is ConeFlexibleType -> this.substituteBounds()?.let {
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.scopes.impl.*
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
|
||||
@@ -124,7 +124,7 @@ fun ConeKotlinType.scopeForSupertype(
|
||||
subClass: FirClass,
|
||||
): FirTypeScope? {
|
||||
if (this !is ConeClassLikeType) return null
|
||||
if (this is ConeClassErrorType) return null
|
||||
if (this is ConeErrorType) return null
|
||||
val symbol = lookupTag.toSymbol(useSiteSession)
|
||||
return if (symbol is FirRegularClassSymbol) {
|
||||
symbol.fir.scopeForClassImpl(
|
||||
|
||||
@@ -362,12 +362,12 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
return isContainedInInvariantOrContravariantPositions
|
||||
}
|
||||
|
||||
override fun createErrorType(debugName: String): ConeClassErrorType {
|
||||
return ConeClassErrorType(ConeIntermediateDiagnostic(debugName))
|
||||
override fun createErrorType(debugName: String): ConeErrorType {
|
||||
return ConeErrorType(ConeIntermediateDiagnostic(debugName))
|
||||
}
|
||||
|
||||
override fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker {
|
||||
return ConeKotlinErrorType(ConeIntermediateDiagnostic("$debugName c: $constructor"))
|
||||
return ConeErrorType(ConeIntermediateDiagnostic("$debugName c: $constructor"))
|
||||
}
|
||||
|
||||
override fun CapturedTypeMarker.captureStatus(): CaptureStatus {
|
||||
|
||||
@@ -89,13 +89,13 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
||||
|
||||
override fun KotlinTypeMarker.isError(): Boolean {
|
||||
assert(this is ConeKotlinType)
|
||||
return this is ConeClassErrorType || this is ConeKotlinErrorType || this.typeConstructor().isError() ||
|
||||
return this is ConeErrorType || this is ConeErrorType || this.typeConstructor().isError() ||
|
||||
(this is ConeClassLikeType && this.lookupTag is ConeClassLikeErrorLookupTag)
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isUninferredParameter(): Boolean {
|
||||
assert(this is ConeKotlinType)
|
||||
return this is ConeClassErrorType && this.isUninferredParameter
|
||||
return this is ConeErrorType && this.isUninferredParameter
|
||||
}
|
||||
|
||||
override fun FlexibleTypeMarker.asDynamicType(): DynamicTypeMarker? {
|
||||
|
||||
@@ -96,7 +96,7 @@ fun <T : ConeKotlinType> T.withArguments(arguments: Array<out ConeTypeProjection
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> this
|
||||
is ConeErrorType -> this
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, arguments, nullability.isNullable) as T
|
||||
is ConeDefinitelyNotNullType -> ConeDefinitelyNotNullType(original.withArguments(arguments)) as T
|
||||
else -> error("Not supported: $this: ${this.render()}")
|
||||
@@ -113,7 +113,7 @@ fun <T : ConeKotlinType> T.withAttributes(attributes: ConeAttributes): T {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> this
|
||||
is ConeErrorType -> this
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, typeArguments, nullability.isNullable, attributes)
|
||||
is ConeDefinitelyNotNullType -> ConeDefinitelyNotNullType(original.withAttributes(attributes))
|
||||
is ConeTypeParameterTypeImpl -> ConeTypeParameterTypeImpl(lookupTag, nullability.isNullable, attributes)
|
||||
@@ -143,7 +143,7 @@ fun <T : ConeKotlinType> T.withNullability(
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> this
|
||||
is ConeErrorType -> this
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, typeArguments, nullability.isNullable, attributes)
|
||||
is ConeTypeParameterTypeImpl -> ConeTypeParameterTypeImpl(lookupTag, nullability.isNullable, attributes)
|
||||
is ConeFlexibleType -> {
|
||||
@@ -223,7 +223,7 @@ fun ConeKotlinType.toFirResolvedTypeRef(
|
||||
source: KtSourceElement? = null,
|
||||
delegatedTypeRef: FirTypeRef? = null
|
||||
): FirResolvedTypeRef {
|
||||
return if (this is ConeKotlinErrorType) {
|
||||
return if (this is ConeErrorType) {
|
||||
buildErrorTypeRef {
|
||||
this.source = source
|
||||
diagnostic = this@toFirResolvedTypeRef.diagnostic
|
||||
@@ -282,7 +282,7 @@ fun FirTypeRef.withReplacedConeType(
|
||||
else
|
||||
this.source
|
||||
|
||||
return if (newType is ConeKotlinErrorType) {
|
||||
return if (newType is ConeErrorType) {
|
||||
buildErrorTypeRef {
|
||||
source = newSource
|
||||
type = newType
|
||||
|
||||
@@ -123,7 +123,7 @@ class FirCallResolver(
|
||||
resultExpression
|
||||
}
|
||||
val typeRef = components.typeFromCallee(resultFunctionCall)
|
||||
if (typeRef.type is ConeKotlinErrorType) {
|
||||
if (typeRef.type is ConeErrorType) {
|
||||
resultFunctionCall.resultType = typeRef
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ fun FirFunction.constructFunctionalType(isSuspend: Boolean = false): ConeLookupT
|
||||
else -> null
|
||||
}
|
||||
val parameters = valueParameters.map {
|
||||
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: ConeKotlinErrorType(
|
||||
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: ConeErrorType(
|
||||
ConeSimpleDiagnostic(
|
||||
"No type for parameter",
|
||||
DiagnosticKind.ValueParameterWithNoTypeAnnotation
|
||||
@@ -235,7 +235,7 @@ fun <T : FirResolvable> BodyResolveComponents.typeFromCallee(access: T): FirReso
|
||||
val implicitReceiver = implicitReceiverStack[labelName]
|
||||
buildResolvedTypeRef {
|
||||
source = null
|
||||
type = implicitReceiver?.type ?: ConeKotlinErrorType(
|
||||
type = implicitReceiver?.type ?: ConeErrorType(
|
||||
ConeSimpleDiagnostic(
|
||||
"Unresolved this@$labelName",
|
||||
DiagnosticKind.UnresolvedLabel
|
||||
|
||||
@@ -61,7 +61,7 @@ class FirSamResolverImpl(
|
||||
getFunctionTypeForPossibleSamType(type.lowerBound)?.lowerBoundIfFlexible() ?: return null,
|
||||
getFunctionTypeForPossibleSamType(type.upperBound)?.upperBoundIfFlexible() ?: return null,
|
||||
)
|
||||
is ConeClassErrorType, is ConeStubType -> null
|
||||
is ConeErrorType, is ConeStubType -> null
|
||||
// TODO: support those types as well
|
||||
is ConeTypeParameterType, is ConeTypeVariableType,
|
||||
is ConeCapturedType, is ConeDefinitelyNotNullType, is ConeIntersectionType,
|
||||
@@ -356,7 +356,7 @@ private val PUBLIC_METHOD_NAMES_IN_OBJECT = setOf("equals", "hashCode", "getClas
|
||||
|
||||
private fun FirSimpleFunction.getFunctionTypeForAbstractMethod(): ConeLookupTagBasedType {
|
||||
val parameterTypes = valueParameters.map {
|
||||
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: ConeKotlinErrorType(ConeIntermediateDiagnostic("No type for parameter $it"))
|
||||
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: ConeErrorType(ConeIntermediateDiagnostic("No type for parameter $it"))
|
||||
}
|
||||
|
||||
return createFunctionalType(
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ private fun buildReflectionType(
|
||||
) to callableReferenceAdaptation
|
||||
}
|
||||
is FirVariable -> createKPropertyType(fir, receiverType, returnTypeRef, candidate) to null
|
||||
else -> ConeClassErrorType(ConeUnsupportedCallableReferenceTarget(candidate)) to null
|
||||
else -> ConeErrorType(ConeUnsupportedCallableReferenceTarget(candidate)) to null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.ResolutionContext
|
||||
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeFixVariableConstraintPosition
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.BodyResolveContext
|
||||
import org.jetbrains.kotlin.fir.returnExpressions
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeVariable
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext
|
||||
@@ -444,7 +444,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
||||
}
|
||||
|
||||
private fun createCannotInferErrorType(message: String, isUninferredParameter: Boolean = false) =
|
||||
ConeClassErrorType(
|
||||
ConeErrorType(
|
||||
ConeSimpleDiagnostic(
|
||||
message,
|
||||
DiagnosticKind.CannotInferParameterType,
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ fun extractLambdaInfoFromFunctionalType(
|
||||
argumentValueParameters.mapIndexed { index, parameter ->
|
||||
parameter.returnTypeRef.coneTypeSafe()
|
||||
?: expectedParameters.getOrNull(index)
|
||||
?: ConeClassErrorType(
|
||||
?: ConeErrorType(
|
||||
ConeSimpleDiagnostic("Cannot infer type for parameter ${parameter.name}", DiagnosticKind.CannotInferParameterType)
|
||||
)
|
||||
}
|
||||
|
||||
+9
-9
@@ -226,12 +226,12 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
} else {
|
||||
ConeUnresolvedQualifierError(typeRef.render())
|
||||
}
|
||||
return ConeKotlinErrorType(diagnostic)
|
||||
return ConeErrorType(diagnostic)
|
||||
}
|
||||
if (symbol is FirTypeParameterSymbol) {
|
||||
for (part in typeRef.qualifier) {
|
||||
if (part.typeArgumentList.typeArguments.isNotEmpty()) {
|
||||
return ConeClassErrorType(
|
||||
return ConeErrorType(
|
||||
ConeUnexpectedTypeArgumentsError("Type arguments not allowed", part.typeArgumentList.source)
|
||||
)
|
||||
}
|
||||
@@ -304,7 +304,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
allTypeArguments.add(substituted)
|
||||
}
|
||||
} else {
|
||||
return ConeClassErrorType(ConeOuterClassArgumentsRequired(parameterClass.symbol))
|
||||
return ConeErrorType(ConeOuterClassArgumentsRequired(parameterClass.symbol))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,14 +403,14 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
symbol: FirClassLikeSymbol<*>,
|
||||
userTypeRef: FirUserTypeRef,
|
||||
qualifierPartArgumentsCount: Int?
|
||||
): ConeClassErrorType? {
|
||||
): ConeErrorType? {
|
||||
// TODO: It should be TYPE_ARGUMENTS_NOT_ALLOWED diagnostics when parameterClass is null
|
||||
val actualTypeParametersCount = getActualTypeParametersCount(parameterClass ?: symbol.fir)
|
||||
|
||||
if (qualifierPartArgumentsCount == null || actualTypeParametersCount != qualifierPartArgumentsCount) {
|
||||
val source = getTypeArgumentsOrNameSource(userTypeRef, qualifierPartIndex)
|
||||
if (source != null) {
|
||||
return ConeClassErrorType(
|
||||
return ConeErrorType(
|
||||
ConeWrongNumberOfTypeArgumentsError(
|
||||
actualTypeParametersCount,
|
||||
parameterClass?.symbol ?: symbol,
|
||||
@@ -484,11 +484,11 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
) to diagnostic
|
||||
}
|
||||
is FirFunctionTypeRef -> createFunctionalType(typeRef) to null
|
||||
is FirDynamicTypeRef -> ConeKotlinErrorType(ConeUnsupportedDynamicType()) to null
|
||||
is FirDynamicTypeRef -> ConeErrorType(ConeUnsupportedDynamicType()) to null
|
||||
is FirIntersectionTypeRef -> {
|
||||
val (leftType, leftDiagnostic) = resolveType(
|
||||
typeRef.leftType
|
||||
?: return ConeKotlinErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
|
||||
?: return ConeErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
|
||||
scopeClassDeclaration,
|
||||
areBareTypesAllowed,
|
||||
isOperandOfIsOperator,
|
||||
@@ -497,7 +497,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
)
|
||||
val (rightType, _) = resolveType(
|
||||
typeRef.rightType
|
||||
?: return ConeKotlinErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
|
||||
?: return ConeErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
|
||||
scopeClassDeclaration,
|
||||
areBareTypesAllowed,
|
||||
isOperandOfIsOperator,
|
||||
@@ -508,7 +508,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
if (rightType.isAny && leftType is ConeTypeParameterType) {
|
||||
ConeDefinitelyNotNullType(leftType) to leftDiagnostic //how properly concat (leftDiagnostic + rightDiagnostic)?
|
||||
} else {
|
||||
ConeKotlinErrorType(ConeUnsupported("Intersection types are not supported yet", typeRef.source)) to null
|
||||
ConeErrorType(ConeUnsupported("Intersection types are not supported yet", typeRef.source)) to null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -500,7 +500,7 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
val typeRef = argument.typeRef as FirResolvedTypeRef
|
||||
buildTypeProjectionWithVariance {
|
||||
source = argument.source
|
||||
this.typeRef = if (typeRef.type is ConeClassErrorType) typeRef else typeRef.withReplacedConeType(type)
|
||||
this.typeRef = if (typeRef.type is ConeErrorType) typeRef else typeRef.withReplacedConeType(type)
|
||||
variance = argument.variance
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -107,7 +107,7 @@ class FirSpecificTypeResolverTransformer(
|
||||
)
|
||||
val resolvedType = resolvedTypeWithDiagnostic.first.takeIfAcceptable()
|
||||
val diagnostic = resolvedTypeWithDiagnostic.second
|
||||
return if (resolvedType != null && resolvedType !is ConeClassErrorType && diagnostic == null) {
|
||||
return if (resolvedType != null && resolvedType !is ConeErrorType && diagnostic == null) {
|
||||
buildResolvedTypeRef {
|
||||
source = functionTypeRef.source
|
||||
type = resolvedType
|
||||
@@ -120,7 +120,7 @@ class FirSpecificTypeResolverTransformer(
|
||||
if (resolvedType != null) {
|
||||
type = resolvedType
|
||||
}
|
||||
this.diagnostic = diagnostic ?: (resolvedType as? ConeClassErrorType)?.diagnostic
|
||||
this.diagnostic = diagnostic ?: (resolvedType as? ConeErrorType)?.diagnostic
|
||||
?: ConeSimpleDiagnostic("Unresolved functional type: ${functionTypeRef.render()}")
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class FirSpecificTypeResolverTransformer(
|
||||
|
||||
private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType, diagnostic: ConeDiagnostic?): FirResolvedTypeRef {
|
||||
return when {
|
||||
resolvedType is ConeClassErrorType -> {
|
||||
resolvedType is ConeErrorType -> {
|
||||
buildErrorTypeRef {
|
||||
val typeRefSourceKind = typeRef.source?.kind
|
||||
val diagnosticSource = resolvedType.diagnostic.safeAs<ConeUnexpectedTypeArgumentsError>()
|
||||
@@ -170,7 +170,7 @@ class FirSpecificTypeResolverTransformer(
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.takeIfAcceptable(): ConeKotlinType? = this.takeUnless {
|
||||
!errorTypeAsResolved && it is ConeClassErrorType
|
||||
!errorTypeAsResolved && it is ConeErrorType
|
||||
}
|
||||
|
||||
override fun transformResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: ScopeClassDeclaration): FirTypeRef {
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ fun FirBlock.writeResultType(session: FirSession) {
|
||||
fun ConstantValueKind<*>.expectedConeType(session: FirSession): ConeKotlinType {
|
||||
fun constructLiteralType(classId: ClassId, isNullable: Boolean = false): ConeKotlinType {
|
||||
val symbol = session.symbolProvider.getClassLikeSymbolByClassId(classId)
|
||||
?: return ConeClassErrorType(ConeSimpleDiagnostic("Missing stdlib class: $classId", DiagnosticKind.MissingStdlibClass))
|
||||
?: return ConeErrorType(ConeSimpleDiagnostic("Missing stdlib class: $classId", DiagnosticKind.MissingStdlibClass))
|
||||
return symbol.toLookupTag().constructClassType(emptyArray(), isNullable)
|
||||
}
|
||||
return when (this) {
|
||||
|
||||
+1
-1
@@ -1067,7 +1067,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
valueParameter.transformReturnTypeRef(
|
||||
StoreType,
|
||||
valueParameter.returnTypeRef.resolvedTypeFromPrototype(
|
||||
ConeKotlinErrorType(
|
||||
ConeErrorType(
|
||||
ConeSimpleDiagnostic(
|
||||
"No type for parameter",
|
||||
DiagnosticKind.ValueParameterWithNoTypeAnnotation
|
||||
|
||||
+1
-1
@@ -998,7 +998,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
is FirSuperReference -> {
|
||||
// TODO: unresolved supertype
|
||||
val supertype = reference.superTypeRef.coneTypeSafe<ConeClassLikeType>()
|
||||
?.takeIf { it !is ConeClassErrorType } ?: return delegatedConstructorCall
|
||||
?.takeIf { it !is ConeErrorType } ?: return delegatedConstructorCall
|
||||
supertype.fullyExpandedType(session)
|
||||
}
|
||||
else -> return delegatedConstructorCall
|
||||
|
||||
@@ -40,7 +40,7 @@ fun FirLookupTrackerComponent.recordTypeResolveAsLookup(typeRef: FirTypeRef, sou
|
||||
if (source == null && fileSource == null) return // TODO: investigate all cases
|
||||
|
||||
fun recordIfValid(type: ConeKotlinType) {
|
||||
if (type is ConeKotlinErrorType) return // TODO: investigate whether some cases should be recorded, e.g. unresolved
|
||||
if (type is ConeErrorType) return // TODO: investigate whether some cases should be recorded, e.g. unresolved
|
||||
type.classId?.let {
|
||||
if (!it.isLocal) {
|
||||
if (it.shortClassName.asString() != "Companion") {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
@@ -86,14 +86,14 @@ infix fun DataFlowVariable.notEq(constant: Boolean?): OperationStatement {
|
||||
infix fun OperationStatement.implies(effect: Statement<*>): Implication = Implication(this, effect)
|
||||
|
||||
infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement =
|
||||
if (type !is ConeClassErrorType) {
|
||||
if (type !is ConeErrorType) {
|
||||
MutableTypeStatement(this, linkedSetOf<ConeKotlinType>().apply { this += type }, HashSet())
|
||||
} else {
|
||||
MutableTypeStatement(this)
|
||||
}
|
||||
|
||||
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
||||
if (type !is ConeClassErrorType) {
|
||||
if (type !is ConeErrorType) {
|
||||
MutableTypeStatement(this, linkedSetOf(), LinkedHashSet<ConeKotlinType>().apply { this += type })
|
||||
} else {
|
||||
MutableTypeStatement(this)
|
||||
|
||||
@@ -171,7 +171,7 @@ private fun ConeClassLikeType.withNullability(nullability: ConeNullability): Con
|
||||
if (nullability == this.nullability) return this
|
||||
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> this
|
||||
is ConeErrorType -> this
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, typeArguments, nullability.isNullable)
|
||||
else -> error("sealed")
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.types
|
||||
object ConeKotlinTypeComparator : Comparator<ConeKotlinType> {
|
||||
private val ConeKotlinType.priority : Int
|
||||
get() = when (this) {
|
||||
is ConeKotlinErrorType -> 8
|
||||
is ConeErrorType -> 8
|
||||
is ConeLookupTagBasedType -> 7
|
||||
is ConeFlexibleType -> 6
|
||||
is ConeCapturedType -> 5
|
||||
@@ -72,8 +72,8 @@ object ConeKotlinTypeComparator : Comparator<ConeKotlinType> {
|
||||
}
|
||||
|
||||
when (a) {
|
||||
is ConeKotlinErrorType -> {
|
||||
require(b is ConeKotlinErrorType) {
|
||||
is ConeErrorType -> {
|
||||
require(b is ConeErrorType) {
|
||||
"priority is inconsistent: ${a.render()} v.s. ${b.render()}"
|
||||
}
|
||||
return a.hashCode() - b.hashCode()
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
|
||||
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.types.impl
|
||||
import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
@@ -22,7 +22,7 @@ internal class FirErrorTypeRefImpl(
|
||||
) : FirErrorTypeRef() {
|
||||
constructor(source: KtSourceElement?, delegatedTypeRef: FirTypeRef?, diagnostic: ConeDiagnostic) : this(
|
||||
source,
|
||||
ConeClassErrorType(diagnostic),
|
||||
ConeErrorType(diagnostic),
|
||||
delegatedTypeRef, diagnostic
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.generatedType
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.type
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeSimpleKotlinType
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -55,7 +55,7 @@ val emptyCfgReferenceType = generatedType("references.impl", "FirEmptyControlFlo
|
||||
val noReceiverExpressionType = generatedType("expressions.impl", "FirNoReceiverExpression")
|
||||
val implicitTypeRefType = generatedType("types.impl", "FirImplicitTypeRefImpl")
|
||||
val firQualifierPartType = type("fir.types", "FirQualifierPart")
|
||||
val coneClassErrorTypeType = type(ConeClassErrorType::class)
|
||||
val ConeErrorTypeType = type(ConeErrorType::class)
|
||||
val simpleNamedReferenceType = generatedType("references.impl", "FirSimpleNamedReference")
|
||||
val explicitThisReferenceType = generatedType("references.impl", "FirExplicitThisReference")
|
||||
val explicitSuperReferenceType = generatedType("references.impl", "FirExplicitSuperReference")
|
||||
|
||||
@@ -276,7 +276,7 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
|
||||
val callee = functionCall.calleeReference
|
||||
if (typeRef is FirResolvedTypeRef) {
|
||||
val type = typeRef.type
|
||||
if (type is ConeKotlinErrorType) {
|
||||
if (type is ConeErrorType) {
|
||||
errorFunctionCallTypes++
|
||||
val psi = callee.psi
|
||||
if (callee is FirErrorNamedReference && psi != null) {
|
||||
@@ -293,7 +293,7 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
|
||||
val callee = qualifiedAccessExpression.calleeReference
|
||||
if (typeRef is FirResolvedTypeRef) {
|
||||
val type = typeRef.type
|
||||
if (type is ConeKotlinErrorType) {
|
||||
if (type is ConeErrorType) {
|
||||
errorQualifiedAccessTypes++
|
||||
val psi = callee.psi
|
||||
if (callee is FirErrorNamedReference && psi != null) {
|
||||
@@ -329,7 +329,7 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
|
||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) {
|
||||
resolvedTypes++
|
||||
val type = resolvedTypeRef.type
|
||||
if (type is ConeKotlinErrorType || type is ConeClassErrorType) {
|
||||
if (type is ConeErrorType || type is ConeErrorType) {
|
||||
errorTypes++
|
||||
if (resolvedTypeRef is FirErrorTypeRef && resolvedTypeRef.diagnostic is ConeStubDiagnostic) {
|
||||
return
|
||||
|
||||
+2
-2
@@ -8,11 +8,11 @@ package org.jetbrains.kotlin.fir
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
|
||||
fun ConeKotlinType.renderForDebugInfo(): String {
|
||||
val nullabilitySuffix = if (this !is ConeKotlinErrorType && this !is ConeClassErrorType) nullability.suffix else ""
|
||||
val nullabilitySuffix = if (this !is ConeErrorType && this !is ConeErrorType) nullability.suffix else ""
|
||||
return when (this) {
|
||||
is ConeTypeVariableType -> "TypeVariable(${this.lookupTag.name})"
|
||||
is ConeDefinitelyNotNullType -> "${original.renderForDebugInfo()}!!"
|
||||
is ConeClassErrorType -> "ERROR CLASS: ${diagnostic.reason}"
|
||||
is ConeErrorType -> "ERROR CLASS: ${diagnostic.reason}"
|
||||
is ConeCapturedType -> "CapturedType(${constructor.projection.renderForDebugInfo()})"
|
||||
is ConeClassLikeType -> {
|
||||
buildString {
|
||||
|
||||
+1
-1
@@ -386,7 +386,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
|
||||
private fun ConeTypeProjection.localTypeRenderer(): String {
|
||||
val nullabilitySuffix = when {
|
||||
this is ConeKotlinType && this !is ConeKotlinErrorType && this !is ConeClassErrorType -> nullability.suffix
|
||||
this is ConeKotlinType && this !is ConeErrorType && this !is ConeErrorType -> nullability.suffix
|
||||
else -> ""
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.classId
|
||||
import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames.CREATOR_NAME
|
||||
@@ -64,7 +64,7 @@ object FirParcelizePropertyChecker : FirPropertyChecker() {
|
||||
reporter: DiagnosticReporter
|
||||
) {
|
||||
val type = property.returnTypeRef.coneType
|
||||
if (type is ConeKotlinErrorType || containingClassSymbol.hasCustomParceler(context.session)) return
|
||||
if (type is ConeErrorType || containingClassSymbol.hasCustomParceler(context.session)) return
|
||||
/*
|
||||
* TODO: abstract code from ParcelSerializer or IrParcelSerializerFactory to avoid duplication
|
||||
* of allowed types checking
|
||||
|
||||
Reference in New Issue
Block a user