[FE 1.0] Refactor error utils: split error entities and introduce error type and error scope kinds
This commit is contained in:
committed by
teamcity
parent
8c1fcddea3
commit
b5933c70e2
+3
-2
@@ -35,7 +35,8 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
|
||||
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.SimpleType
|
||||
|
||||
@@ -120,7 +121,7 @@ open class ParcelableResolveExtension : SyntheticResolveExtension {
|
||||
&& result.none { it.isWriteToParcel() }
|
||||
) {
|
||||
val builtIns = thisDescriptor.builtIns
|
||||
val parcelClassType = resolveParcelClassType(thisDescriptor.module) ?: ErrorUtils.createErrorType("Unresolved 'Parcel' type")
|
||||
val parcelClassType = resolveParcelClassType(thisDescriptor.module) ?: ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_PARCEL_TYPE)
|
||||
result += createMethod(
|
||||
thisDescriptor, WRITE_TO_PARCEL, Modality.OPEN,
|
||||
builtIns.unitType, "parcel" to parcelClassType, "flags" to builtIns.intType
|
||||
|
||||
+3
-2
@@ -24,7 +24,8 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
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.SimpleType
|
||||
import java.util.*
|
||||
|
||||
@@ -67,7 +68,7 @@ internal class SyntheticElementResolveContext(
|
||||
val layoutContainer: SimpleType?
|
||||
) {
|
||||
companion object {
|
||||
private fun errorType() = ErrorUtils.createErrorType("")
|
||||
private fun errorType() = ErrorUtils.createErrorType(ErrorTypeKind.SYNTHETIC_ELEMENT_ERROR_TYPE)
|
||||
val ERROR_CONTEXT = SyntheticElementResolveContext(errorType(), errorType(), null, errorType(), null, null, null)
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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() }
|
||||
|
||||
+3
-1
@@ -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) {
|
||||
|
||||
+3
-2
@@ -41,7 +41,8 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||
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.SimpleType
|
||||
|
||||
@@ -141,7 +142,7 @@ open class ParcelizeResolveExtension : SyntheticResolveExtension {
|
||||
&& result.none { it.isWriteToParcel() }
|
||||
) {
|
||||
val builtIns = thisDescriptor.builtIns
|
||||
val parcelClassType = resolveParcelClassType(thisDescriptor.module) ?: ErrorUtils.createErrorType("Unresolved 'Parcel' type")
|
||||
val parcelClassType = resolveParcelClassType(thisDescriptor.module) ?: ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_PARCEL_TYPE)
|
||||
result += createMethod(
|
||||
thisDescriptor, WRITE_TO_PARCEL, Modality.OPEN,
|
||||
builtIns.unitType, "parcel" to parcelClassType, "flags" to builtIns.intType
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.CallHandle
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.*
|
||||
import java.util.*
|
||||
@@ -142,7 +143,7 @@ class FuzzyType(
|
||||
valueTransform = {
|
||||
val typeProjection = TypeProjectionImpl(Variance.INVARIANT, it.defaultType)
|
||||
val substitutedProjection = substitutorToKeepCapturedTypes.substitute(typeProjection)
|
||||
substitutedProjection?.takeUnless { ErrorUtils.containsUninferredParameter(it.type) } ?: typeProjection
|
||||
substitutedProjection?.takeUnless { ErrorUtils.containsUninferredTypeVariable(it.type) } ?: typeProjection
|
||||
})
|
||||
return TypeConstructorSubstitution.createByConstructorsMap(substitutionMap, approximateCapturedTypes = true).buildSubstitutor()
|
||||
}
|
||||
|
||||
+4
-1
@@ -10,6 +10,9 @@ package org.jetbrains.kotlin.scripting.ide_common.idea.util
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
|
||||
import org.jetbrains.kotlin.types.typeUtil.nullability
|
||||
import org.jetbrains.kotlin.types.typeUtil.substitute
|
||||
@@ -73,6 +76,6 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
|
||||
constructor,
|
||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||
isMarkedNullable,
|
||||
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
||||
ErrorUtils.createErrorScope(ErrorScopeKind.UNSUPPORTED_TYPE_SCOPE, true)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user