[FE 1.0] Refactor error utils: split error entities and introduce error type and error scope kinds

This commit is contained in:
Victor Petukhov
2022-03-17 13:32:36 +04:00
committed by teamcity
parent 8c1fcddea3
commit b5933c70e2
139 changed files with 1061 additions and 1204 deletions
@@ -63,7 +63,8 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny
import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.error.ErrorTypeKind
import org.jetbrains.kotlin.types.error.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.isError
import org.jetbrains.kotlin.types.typeUtil.isEnum
@@ -530,7 +531,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
assert(correctErrorTypes)
return getNonErrorType<JCExpression>(
ErrorUtils.createErrorType("Error super class"),
ErrorUtils.createErrorType(ErrorTypeKind.ERROR_SUPER_TYPE),
ErrorTypeCorrector.TypeKind.SUPER_TYPE,
ref
) { throw SuperTypeCalculationFailure() }
@@ -34,6 +34,8 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
import org.jetbrains.kotlin.types.error.ErrorUtils
import org.jetbrains.kotlin.types.error.ErrorTypeKind
private typealias SubstitutionMap = Map<String, Pair<KtTypeParameter, KtTypeProjection>>
@@ -137,7 +139,7 @@ class ErrorTypeCorrector(
if (arguments.isEmpty()) return baseExpression
val typeReference = PsiTreeUtil.getParentOfType(type, KtTypeReference::class.java, true)
val kotlinType = bindingContext[BindingContext.TYPE, typeReference] ?: ErrorUtils.createErrorType("Kapt error type")
val kotlinType = bindingContext[BindingContext.TYPE, typeReference] ?: ErrorUtils.createErrorType(ErrorTypeKind.KAPT_ERROR_TYPE)
val typeSystem = SimpleClassicTypeSystemContext
val typeMappingMode = when (typeKind) {