[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
+14
-8
@@ -28,7 +28,8 @@ import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.util.getType
|
||||
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.resolve.sam.getFunctionTypeForAbstractMethod
|
||||
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.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.intersectWrappedTypes
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
@@ -73,7 +74,7 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (typeReference != null) {
|
||||
val bindingContext = analysisContext.analyze(typeReference, AnalysisMode.PARTIAL)
|
||||
val kotlinType = bindingContext[BindingContext.TYPE, typeReference]
|
||||
?: ErrorUtils.createErrorType("Return type \"${typeReference.text}\" cannot be resolved")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE, typeReference.text)
|
||||
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
@@ -82,7 +83,7 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (declaration is KtFunction && declaration !is KtConstructor<*> && declaration.equalsToken != null) {
|
||||
val bindingContext = analysisContext.analyze(declaration)
|
||||
val kotlinType = bindingContext[BindingContext.FUNCTION, declaration]?.returnType
|
||||
?: ErrorUtils.createErrorType("Implicit return type for function \"${declaration.name}\" cannot be resolved")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.IMPLICIT_RETURN_TYPE_FOR_FUNCTION, declaration.name ?: "<unknown>")
|
||||
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
@@ -90,7 +91,7 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (declaration is KtProperty) {
|
||||
val bindingContext = analysisContext.analyze(declaration)
|
||||
val kotlinType = bindingContext[BindingContext.VARIABLE, declaration]?.returnType
|
||||
?: ErrorUtils.createErrorType("Implicit return type for property \"${declaration.name}\" cannot be resolved")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.IMPLICIT_RETURN_TYPE_FOR_PROPERTY, declaration.name ?: "<unknown>")
|
||||
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
@@ -98,7 +99,9 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (declaration is KtPropertyAccessor) {
|
||||
val bindingContext = analysisContext.analyze(declaration)
|
||||
val kotlinType = bindingContext[BindingContext.PROPERTY_ACCESSOR, declaration]?.returnType
|
||||
?: ErrorUtils.createErrorType("Return type for property accessor \"${declaration.property.name}\" cannot be resolved")
|
||||
?: ErrorUtils.createErrorType(
|
||||
ErrorTypeKind.IMPLICIT_RETURN_TYPE_FOR_PROPERTY_ACCESSOR, declaration.property.name ?: "<unknown>"
|
||||
)
|
||||
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
@@ -112,7 +115,7 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (property != null && property.setter == propertyAccessor) {
|
||||
val bindingContext = analysisContext.analyze(property)
|
||||
val kotlinType = bindingContext[BindingContext.VARIABLE, property]?.returnType
|
||||
?: ErrorUtils.createErrorType("Return type for property \"${declaration.name}\" cannot be resolved")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE_FOR_PROPERTY, declaration.name ?: "<unknown>")
|
||||
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
@@ -122,7 +125,9 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (declaration is KtConstructor<*>) {
|
||||
val bindingContext = analysisContext.analyze(declaration)
|
||||
val kotlinType = bindingContext[BindingContext.CONSTRUCTOR, declaration]?.returnType
|
||||
?: ErrorUtils.createErrorType("Return type for constructor \"${declaration.containingClass()?.name}\" cannot be resolved")
|
||||
?: ErrorUtils.createErrorType(
|
||||
ErrorTypeKind.RETURN_TYPE_FOR_CONSTRUCTOR, declaration.containingClass()?.name ?: "<unknown>"
|
||||
)
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
|
||||
@@ -146,7 +151,8 @@ class KtFe10ExpressionTypeProvider(
|
||||
}
|
||||
|
||||
val errorMessage = "Descriptor not found for function \"${declaration.name}\""
|
||||
return ErrorUtils.createErrorTypeWithCustomConstructor(errorMessage, function.typeConstructor).toKtType(analysisContext)
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_DESCRIPTOR_FOR_FUNCTION, function.typeConstructor, errorMessage)
|
||||
.toKtType(analysisContext)
|
||||
}
|
||||
|
||||
override fun getExpectedType(expression: PsiElement): KtType? = withValidityAssertion {
|
||||
|
||||
+6
-3
@@ -26,6 +26,9 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
internal class KtFe10TypeCreator(
|
||||
@@ -48,8 +51,8 @@ internal class KtFe10TypeCreator(
|
||||
}
|
||||
|
||||
if (descriptor == null) {
|
||||
val kotlinType = ErrorUtils.createErrorType("Cannot build class type, descriptor not found for builder $builder")
|
||||
return KtFe10ClassErrorType(kotlinType as ErrorType, analysisContext)
|
||||
val kotlinType = ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_DESCRIPTOR_FOR_CLASS, builder.toString())
|
||||
return KtFe10ClassErrorType(kotlinType, analysisContext)
|
||||
}
|
||||
|
||||
val typeParameters = descriptor.typeConstructor.parameters
|
||||
@@ -77,7 +80,7 @@ internal class KtFe10TypeCreator(
|
||||
}
|
||||
}
|
||||
val kotlinType = descriptor?.defaultType
|
||||
?: ErrorUtils.createErrorType("Cannot build type parameter type, descriptor not found for builder $builder")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_DESCRIPTOR_FOR_TYPE_PARAMETER, builder.toString())
|
||||
return kotlinType.toKtType(analysisContext) as KtTypeParameterType
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -45,6 +45,9 @@ import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||
import org.jetbrains.kotlin.util.containingNonLocalDeclaration
|
||||
|
||||
@@ -71,7 +74,7 @@ internal class KtFe10TypeProvider(
|
||||
|
||||
override fun buildSelfClassType(symbol: KtNamedClassOrObjectSymbol): KtType = withValidityAssertion {
|
||||
val kotlinType = (getSymbolDescriptor(symbol) as? ClassDescriptor)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Cannot get class type for unresolved class ${symbol.nameOrAnonymous}")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_CLASS_TYPE, symbol.nameOrAnonymous.toString())
|
||||
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
@@ -84,7 +87,7 @@ internal class KtFe10TypeProvider(
|
||||
override fun getKtType(ktTypeReference: KtTypeReference): KtType = withValidityAssertion {
|
||||
val bindingContext = analysisContext.analyze(ktTypeReference, AnalysisMode.PARTIAL)
|
||||
val kotlinType = bindingContext[BindingContext.TYPE, ktTypeReference]
|
||||
?: ErrorUtils.createErrorType("Cannot resolve type reference ${ktTypeReference.text}")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, ktTypeReference.text)
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -50,6 +50,9 @@ import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
internal val MemberDescriptor.ktSymbolKind: KtSymbolKind
|
||||
get() {
|
||||
@@ -229,7 +232,7 @@ internal fun KotlinType.toKtType(analysisContext: Fe10AnalysisContext): KtType {
|
||||
return if (newTypeParameterDescriptor != null) {
|
||||
KtFe10TypeParameterType(unwrappedType, newTypeParameterDescriptor, analysisContext)
|
||||
} else {
|
||||
KtFe10ClassErrorType(ErrorUtils.createErrorType("Unresolved type parameter type") as ErrorType, analysisContext)
|
||||
KtFe10ClassErrorType(ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE_PARAMETER_TYPE), analysisContext)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +244,8 @@ internal fun KotlinType.toKtType(analysisContext: Fe10AnalysisContext): KtType {
|
||||
is FunctionClassDescriptor -> KtFe10FunctionalType(unwrappedType, typeDeclaration, analysisContext)
|
||||
is ClassDescriptor -> KtFe10UsualClassType(unwrappedType, typeDeclaration, analysisContext)
|
||||
else -> {
|
||||
val errorType = ErrorUtils.createErrorTypeWithCustomConstructor("Unresolved class type", typeConstructor)
|
||||
KtFe10ClassErrorType(errorType as ErrorType, analysisContext)
|
||||
val errorType = ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_CLASS_TYPE, typeConstructor, typeDeclaration.toString())
|
||||
KtFe10ClassErrorType(errorType, analysisContext)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -26,12 +26,11 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasBody
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isTopLevelInFileOrScript
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.types.ErrorType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
internal val KtDeclaration.ktVisibility: Visibility?
|
||||
get() = when {
|
||||
@@ -149,6 +148,6 @@ internal fun PsiElement.getResolutionScope(bindingContext: BindingContext): Lexi
|
||||
|
||||
|
||||
internal fun KtFe10Symbol.createErrorType(): KtType {
|
||||
val type = ErrorUtils.createErrorType("Type is unavailable for declaration $psi") as ErrorType
|
||||
val type = ErrorUtils.createErrorType(ErrorTypeKind.UNAVAILABLE_TYPE_FOR_DECLARATION, psi.toString())
|
||||
return KtFe10ClassErrorType(type, analysisContext)
|
||||
}
|
||||
+2
-2
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.analysis.api.symbols.KtClassLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtClassErrorType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeNullability
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.types.ErrorType
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
|
||||
internal class KtFe10ClassErrorType(
|
||||
override val type: ErrorType,
|
||||
@@ -23,7 +23,7 @@ internal class KtFe10ClassErrorType(
|
||||
override fun asStringForDebugging(): String = withValidityAssertion { type.asStringForDebugging() }
|
||||
|
||||
override val error: String
|
||||
get() = withValidityAssertion { "Type \"${type.presentableName}\" is unresolved" }
|
||||
get() = withValidityAssertion { "Type \"${type.debugMessage}\" is unresolved" }
|
||||
|
||||
override val candidateClassSymbols: Collection<KtClassLikeSymbol>
|
||||
get() = withValidityAssertion { emptyList() }
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
internal class KtFe10TypeRenderer(private val options: KtTypeRendererOptions, private val isDebugText: Boolean = false) {
|
||||
|
||||
+7
-3
@@ -14,6 +14,8 @@ import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContext
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
@@ -43,7 +45,8 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping(
|
||||
|
||||
override fun TypeConstructorMarker.defaultType(): KotlinTypeMarker {
|
||||
require(this is TypeConstructor)
|
||||
val declaration = declarationDescriptor ?: return ErrorUtils.createErrorType("Unresolved declaration descriptor ($this)")
|
||||
val declaration = declarationDescriptor
|
||||
?: return ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_DECLARATION, this.toString())
|
||||
return declaration.defaultType
|
||||
}
|
||||
|
||||
@@ -78,7 +81,7 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping(
|
||||
val declaration = declarationDescriptor
|
||||
if (declaration == null) {
|
||||
val errorArguments = arguments.map { TypeProjectionImpl(it as KotlinType) }
|
||||
return ErrorUtils.createErrorTypeWithArguments("Unresolved type constructor $this", errorArguments)
|
||||
return ErrorUtils.createErrorTypeWithArguments(ErrorTypeKind.UNRESOLVED_TYPE, errorArguments, this.toString())
|
||||
}
|
||||
|
||||
val substitutions = LinkedHashMap<TypeConstructor, TypeProjection>(parameters.size)
|
||||
@@ -106,7 +109,8 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping(
|
||||
override fun continuationTypeConstructor(): TypeConstructorMarker {
|
||||
val continuationFqName = StandardClassIds.Continuation.asSingleFqName()
|
||||
val foundClasses = resolveSession.getTopLevelClassifierDescriptors(continuationFqName, NoLookupLocation.FROM_IDE)
|
||||
return foundClasses.firstOrNull()?.typeConstructor ?: ErrorUtils.createErrorTypeConstructor("Cannot find $continuationFqName")
|
||||
return foundClasses.firstOrNull()?.typeConstructor
|
||||
?: ErrorUtils.createErrorTypeConstructor(ErrorTypeKind.NOT_FOUND_FQNAME, continuationFqName.toString())
|
||||
}
|
||||
|
||||
override fun functionNTypeConstructor(n: Int): TypeConstructorMarker {
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
|
||||
@@ -34,7 +34,8 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor;
|
||||
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.org.objectweb.asm.FieldVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
@@ -483,7 +484,7 @@ public class PropertyCodegen {
|
||||
|
||||
if (delegateType == null) {
|
||||
// Delegation convention is unresolved
|
||||
delegateType = ErrorUtils.createErrorType("Delegate type");
|
||||
delegateType = ErrorUtils.createErrorType(ErrorTypeKind.TYPE_FOR_DELEGATION, delegateExpression.getText());
|
||||
}
|
||||
return delegateType;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
+4
-5
@@ -38,10 +38,9 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
@@ -277,7 +276,7 @@ fun ModuleDescriptor.getResult(kotlinType: KotlinType) =
|
||||
it,
|
||||
arguments = listOf(kotlinType.asTypeProjection())
|
||||
)
|
||||
} ?: ErrorUtils.createErrorType("For Result")
|
||||
} ?: ErrorUtils.createErrorType(ErrorTypeKind.TYPE_FOR_RESULT)
|
||||
|
||||
fun FunctionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm() =
|
||||
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineUninterceptedOrReturn() == true
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.serialization.AnnotationSerializer
|
||||
import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase
|
||||
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnresolvedType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnresolvedType
|
||||
|
||||
class BuiltInsSerializerExtension : KotlinSerializerExtensionBase(BuiltInSerializerProtocol) {
|
||||
private val shortNameToClassId = mapOf(
|
||||
@@ -52,9 +52,9 @@ class BuiltInsSerializerExtension : KotlinSerializerExtensionBase(BuiltInSeriali
|
||||
private val KotlinType.presentableName: String
|
||||
get() {
|
||||
val unwrapped = unwrap()
|
||||
if (unwrapped !is UnresolvedType) {
|
||||
throw UnsupportedOperationException("Error types which are not UnresolvedType instances are not supported here: $unwrapped")
|
||||
if (!isUnresolvedType(unwrapped)) {
|
||||
throw UnsupportedOperationException("Error types which are not unresolved type instances are not supported here: $unwrapped")
|
||||
}
|
||||
return unwrapped.presentableName
|
||||
return unwrapped.debugMessage.removePrefix("Unresolved type for ")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,8 +368,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
return ConeErrorType(ConeIntermediateDiagnostic(debugName))
|
||||
}
|
||||
|
||||
override fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker {
|
||||
return ConeErrorType(ConeIntermediateDiagnostic("$debugName c: $constructor"))
|
||||
override fun createUninferredType(constructor: TypeConstructorMarker): KotlinTypeMarker {
|
||||
return ConeErrorType(ConeIntermediateDiagnostic("Uninferred type c: $constructor"))
|
||||
}
|
||||
|
||||
override fun CapturedTypeMarker.captureStatus(): CaptureStatus {
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure
|
||||
|
||||
@@ -41,7 +42,7 @@ object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
c: ResolutionContext<*>
|
||||
) {
|
||||
val expectedType = c.expectedType
|
||||
if (TypeUtils.noExpectedType(expectedType) || ErrorUtils.containsErrorType(expectedType) || ErrorUtils.containsUninferredParameter(expectedType)) return
|
||||
if (TypeUtils.noExpectedType(expectedType) || ErrorUtils.containsErrorType(expectedType) || ErrorUtils.containsUninferredTypeVariable(expectedType)) return
|
||||
|
||||
// optimization: if no arguments or flexibility, everything is OK
|
||||
if (expectedType.arguments.isEmpty() || !expectedType.isFlexible()) return
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.analyzer
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import java.io.File
|
||||
|
||||
open class AnalysisResult protected constructor(
|
||||
@@ -58,12 +58,12 @@ open class AnalysisResult protected constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private class CompilationError(bindingContext: BindingContext) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule())
|
||||
private class CompilationError(bindingContext: BindingContext) : AnalysisResult(bindingContext, ErrorUtils.errorModule)
|
||||
|
||||
private class InternalError(
|
||||
bindingContext: BindingContext,
|
||||
val exception: Throwable
|
||||
) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule())
|
||||
) : AnalysisResult(bindingContext, ErrorUtils.errorModule)
|
||||
|
||||
class RetryWithAdditionalRoots(
|
||||
bindingContext: BindingContext,
|
||||
@@ -75,7 +75,7 @@ open class AnalysisResult protected constructor(
|
||||
) : AnalysisResult(bindingContext, moduleDescriptor)
|
||||
|
||||
companion object {
|
||||
val EMPTY: AnalysisResult = success(BindingContext.EMPTY, ErrorUtils.getErrorModule())
|
||||
val EMPTY: AnalysisResult = success(BindingContext.EMPTY, ErrorUtils.errorModule)
|
||||
|
||||
@JvmStatic
|
||||
fun success(bindingContext: BindingContext, module: ModuleDescriptor): AnalysisResult {
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
|
||||
import java.util.HashMap
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
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.KotlinType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -119,12 +120,12 @@ public class AnnotationResolverImpl extends AnnotationResolver {
|
||||
) {
|
||||
KtTypeReference typeReference = entryElement.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
return ErrorUtils.createErrorType("No type reference: " + entryElement.getText());
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, entryElement.getText());
|
||||
}
|
||||
|
||||
KotlinType type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||
return ErrorUtils.createErrorType("Not an annotation: " + type);
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.NOT_ANNOTATION_TYPE_IN_ANNOTATION_CONTEXT, type.toString());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.StubTypesBasedInferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.PSIPartialCallInfo
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
@@ -52,6 +52,8 @@ import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
||||
import org.jetbrains.kotlin.types.TypeUtils.noExpectedType
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.createFakeExpressionOfType
|
||||
@@ -737,7 +739,7 @@ class DelegatedPropertyResolver(
|
||||
val pretendReturnType = call.getResolvedCall(trace.bindingContext)?.resultingDescriptor?.returnType
|
||||
return pretendReturnType?.takeIf { it.isProperType() }
|
||||
?: delegateType.takeIf { it.isProperType() }
|
||||
?: ErrorUtils.createErrorType("Type for ${delegateExpression.text}")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.TYPE_FOR_DELEGATION, delegateExpression.text)
|
||||
}
|
||||
|
||||
private fun KotlinType.isProperType(): Boolean {
|
||||
|
||||
@@ -61,6 +61,8 @@ import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.*;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
|
||||
@@ -222,7 +224,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.add(ErrorUtils.createErrorType("No type reference"));
|
||||
result.add(ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, delegationSpecifier.getText()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -691,7 +693,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
else {
|
||||
// Error is reported by the parser
|
||||
type = ErrorUtils.createErrorType("Annotation is absent");
|
||||
type = ErrorUtils.createErrorType(ErrorTypeKind.NO_TYPE_SPECIFIED, parameter.getText());
|
||||
}
|
||||
if (parameter.hasModifier(VARARG_KEYWORD)) {
|
||||
return getVarargParameterType(type);
|
||||
@@ -765,8 +767,8 @@ public class DescriptorResolver {
|
||||
if (typeReference == null) {
|
||||
typeAliasDescriptor.initialize(
|
||||
typeParameterDescriptors,
|
||||
ErrorUtils.createErrorType(name.asString()),
|
||||
ErrorUtils.createErrorType(name.asString()));
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE_ALIAS, name.asString()),
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE_ALIAS, name.asString()));
|
||||
}
|
||||
else if (!languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
||||
typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace);
|
||||
@@ -775,19 +777,19 @@ public class DescriptorResolver {
|
||||
TuplesKt.to(LanguageFeature.TypeAliases, languageVersionSettings)));
|
||||
typeAliasDescriptor.initialize(
|
||||
typeParameterDescriptors,
|
||||
ErrorUtils.createErrorType(name.asString()),
|
||||
ErrorUtils.createErrorType(name.asString()));
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE_ALIAS, name.asString()),
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE_ALIAS, name.asString()));
|
||||
}
|
||||
else {
|
||||
typeAliasDescriptor.initialize(
|
||||
typeParameterDescriptors,
|
||||
storageManager.createRecursionTolerantLazyValue(
|
||||
() -> typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace),
|
||||
ErrorUtils.createErrorType("Recursive type alias expansion for " + typeAliasDescriptor.getName().asString())
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.RECURSIVE_TYPE_ALIAS, typeAliasDescriptor.getName().asString())
|
||||
),
|
||||
storageManager.createRecursionTolerantLazyValue(
|
||||
() -> typeResolver.resolveExpandedTypeForTypeAlias(typeAliasDescriptor),
|
||||
ErrorUtils.createErrorType("Recursive type alias expansion for " + typeAliasDescriptor.getName().asString())
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.RECURSIVE_TYPE_ALIAS, typeAliasDescriptor.getName().asString())
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1232,7 +1234,7 @@ public class DescriptorResolver {
|
||||
getterType = propertyTypeIfKnown;
|
||||
}
|
||||
|
||||
getterDescriptor.initialize(getterType != null ? getterType : VariableTypeAndInitializerResolver.STUB_FOR_PROPERTY_WITHOUT_TYPE);
|
||||
getterDescriptor.initialize(getterType != null ? getterType : VariableTypeAndInitializerResolver.getTypeForPropertyWithoutReturnType(propertyDescriptor.getName().asString()));
|
||||
|
||||
return getterDescriptor;
|
||||
}
|
||||
|
||||
@@ -58,15 +58,14 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.TraceBasedLocalRedeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionExpression
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionLiteral
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
import java.util.*
|
||||
|
||||
@@ -166,7 +165,7 @@ class FunctionDescriptorResolver(
|
||||
trace, scope, dataFlowInfo, function, functionDescriptor, inferenceSession
|
||||
)
|
||||
else ->
|
||||
ErrorUtils.createErrorType("No type, no body")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE, functionDescriptor.name.asString())
|
||||
}
|
||||
functionDescriptor.setReturnType(inferredReturnType)
|
||||
}
|
||||
@@ -486,10 +485,10 @@ class FunctionDescriptorResolver(
|
||||
trace.report(CANNOT_INFER_PARAMETER_TYPE.on(valueParameter))
|
||||
}
|
||||
|
||||
expectedType ?: TypeUtils.CANT_INFER_FUNCTION_PARAM_TYPE
|
||||
expectedType ?: TypeUtils.CANNOT_INFER_FUNCTION_PARAM_TYPE
|
||||
} else {
|
||||
trace.report(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION.on(valueParameter))
|
||||
ErrorUtils.createErrorType("Type annotation was missing for parameter ${valueParameter.nameAsSafeName}")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.MISSED_TYPE_FOR_PARAMETER, valueParameter.nameAsSafeName.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.results.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasLowPriorityInOverloadResolution
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtensionProperty
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
|
||||
object OverloadabilitySpecificityCallbacks : SpecificityComparisonCallbacks {
|
||||
|
||||
@@ -56,6 +56,10 @@ import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorScope
|
||||
import org.jetbrains.kotlin.types.error.ThrowingScope
|
||||
import org.jetbrains.kotlin.types.extensions.TypeAttributeTranslators
|
||||
import org.jetbrains.kotlin.types.typeUtil.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
@@ -96,8 +100,8 @@ class TypeResolver(
|
||||
).unwrap()
|
||||
return when (resolvedType) {
|
||||
is DynamicType -> {
|
||||
trace.report(Errors.TYPEALIAS_SHOULD_EXPAND_TO_CLASS.on(typeReference, resolvedType))
|
||||
ErrorUtils.createErrorType("dynamic type in wrong context")
|
||||
trace.report(TYPEALIAS_SHOULD_EXPAND_TO_CLASS.on(typeReference, resolvedType))
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.PROHIBITED_DYNAMIC_TYPE)
|
||||
}
|
||||
is SimpleType -> resolvedType
|
||||
else -> error("Unexpected type: $resolvedType")
|
||||
@@ -238,7 +242,7 @@ class TypeResolver(
|
||||
val hasSuspendModifier = outerModifierList?.hasModifier(KtTokens.SUSPEND_KEYWORD) ?: false
|
||||
val suspendModifier by lazy { outerModifierList?.getModifier(KtTokens.SUSPEND_KEYWORD) }
|
||||
if (hasSuspendModifier && !typeElement.canHaveFunctionTypeModifiers()) {
|
||||
c.trace.report(Errors.WRONG_MODIFIER_TARGET.on(suspendModifier!!, KtTokens.SUSPEND_KEYWORD, "non-functional type"))
|
||||
c.trace.report(WRONG_MODIFIER_TARGET.on(suspendModifier!!, KtTokens.SUSPEND_KEYWORD, "non-functional type"))
|
||||
} else if (hasSuspendModifier) {
|
||||
checkCoroutinesFeature(languageVersionSettings, c.trace, suspendModifier!!)
|
||||
}
|
||||
@@ -250,9 +254,10 @@ class TypeResolver(
|
||||
|
||||
if (classifier == null) {
|
||||
val arguments = resolveTypeProjections(
|
||||
c, ErrorUtils.createErrorType("No type").constructor, qualifierResolutionResult.allProjections
|
||||
c, ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, typeElement.text).constructor, qualifierResolutionResult.allProjections
|
||||
)
|
||||
result = type(ErrorUtils.createUnresolvedType(type.getDebugText(), arguments))
|
||||
val unresolvedType = ErrorUtils.createErrorTypeWithArguments(ErrorTypeKind.UNRESOLVED_TYPE, arguments, type.getDebugText())
|
||||
result = type(unresolvedType)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -504,7 +509,7 @@ class TypeResolver(
|
||||
}
|
||||
})
|
||||
|
||||
return result ?: type(ErrorUtils.createErrorType(typeElement?.getDebugText() ?: "No type element"))
|
||||
return result ?: type(ErrorUtils.createErrorType(ErrorTypeKind.NO_TYPE_SPECIFIED, typeElement?.getDebugText() ?: "unknown element"))
|
||||
}
|
||||
|
||||
private fun KtTypeElement?.canHaveFunctionTypeModifiers(): Boolean =
|
||||
@@ -519,7 +524,7 @@ class TypeResolver(
|
||||
val scopeForTypeParameter = getScopeForTypeParameter(c, typeParameter)
|
||||
|
||||
if (typeArgumentList != null) {
|
||||
resolveTypeProjections(c, ErrorUtils.createErrorType("No type").constructor, typeArgumentList.arguments)
|
||||
resolveTypeProjections(c, ErrorUtils.createErrorType(ErrorTypeKind.ERROR_TYPE_PARAMETER).constructor, typeArgumentList.arguments)
|
||||
c.trace.report(TYPE_ARGUMENTS_NOT_ALLOWED.on(typeArgumentList, "for type parameters"))
|
||||
}
|
||||
|
||||
@@ -528,8 +533,8 @@ class TypeResolver(
|
||||
DescriptorResolver.checkHasOuterClassInstance(c.scope, c.trace, referenceExpression, containing)
|
||||
}
|
||||
|
||||
return if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
||||
ErrorUtils.createErrorType("?")
|
||||
return if (scopeForTypeParameter is ErrorScope && scopeForTypeParameter !is ThrowingScope)
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.ERROR_TYPE_PARAMETER)
|
||||
else
|
||||
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
typeAttributeTranslators.toAttributes(annotations, typeParameter.typeConstructor, containing),
|
||||
@@ -831,8 +836,9 @@ class TypeResolver(
|
||||
): PossiblyBareType =
|
||||
type(
|
||||
ErrorUtils.createErrorTypeWithArguments(
|
||||
typeConstructor.declarationDescriptor?.name?.asString() ?: typeConstructor.toString(),
|
||||
resolveTypeProjectionsWithErrorConstructor(c, arguments)
|
||||
ErrorTypeKind.TYPE_FOR_ERROR_TYPE_CONSTRUCTOR,
|
||||
resolveTypeProjectionsWithErrorConstructor(c, arguments),
|
||||
typeConstructor.declarationDescriptor?.name?.asString() ?: typeConstructor.toString()
|
||||
)
|
||||
)
|
||||
|
||||
@@ -960,7 +966,7 @@ class TypeResolver(
|
||||
c: TypeResolutionContext,
|
||||
argumentElements: List<KtTypeProjection>,
|
||||
message: String = "Error type for resolving type projections"
|
||||
) = resolveTypeProjections(c, ErrorUtils.createErrorTypeConstructor(message), argumentElements)
|
||||
) = resolveTypeProjections(c, ErrorUtils.createErrorTypeConstructor(ErrorTypeKind.TYPE_FOR_ERROR_TYPE_CONSTRUCTOR, message), argumentElements)
|
||||
|
||||
/**
|
||||
* For cases like:
|
||||
@@ -992,7 +998,7 @@ class TypeResolver(
|
||||
val parameterDescriptor = parameters[i]
|
||||
TypeUtils.makeStarProjection(parameterDescriptor)
|
||||
} else {
|
||||
TypeProjectionImpl(OUT_VARIANCE, ErrorUtils.createErrorType("*"))
|
||||
TypeProjectionImpl(OUT_VARIANCE, ErrorUtils.createErrorType(ErrorTypeKind.ERROR_TYPE_PROJECTION))
|
||||
}
|
||||
} else {
|
||||
val type = resolveType(c.noBareTypes(), argumentElement.typeReference!!)
|
||||
|
||||
+7
-4
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor
|
||||
|
||||
@@ -37,8 +39,9 @@ class VariableTypeAndInitializerResolver(
|
||||
private val anonymousTypeTransformers: Iterable<DeclarationSignatureAnonymousTypeTransformer>
|
||||
) {
|
||||
companion object {
|
||||
@JvmField
|
||||
val STUB_FOR_PROPERTY_WITHOUT_TYPE = ErrorUtils.createErrorType("No type, no body")
|
||||
@JvmStatic
|
||||
fun getTypeForPropertyWithoutReturnType(property: String): SimpleType =
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE_FOR_PROPERTY, property)
|
||||
}
|
||||
|
||||
fun resolveType(
|
||||
@@ -58,7 +61,7 @@ class VariableTypeAndInitializerResolver(
|
||||
trace.report(VARIABLE_WITH_NO_TYPE_NO_INITIALIZER.on(variable))
|
||||
}
|
||||
|
||||
return STUB_FOR_PROPERTY_WITHOUT_TYPE
|
||||
return getTypeForPropertyWithoutReturnType(variableDescriptor.name.asString())
|
||||
}
|
||||
|
||||
fun resolveTypeNullable(
|
||||
@@ -165,7 +168,7 @@ class VariableTypeAndInitializerResolver(
|
||||
)
|
||||
|
||||
val delegatedType = getterReturnType?.let { approximateType(it, local) }
|
||||
?: ErrorUtils.createErrorType("Type from delegate")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.TYPE_FOR_DELEGATION, delegateExpression.text)
|
||||
|
||||
transformAnonymousTypeIfNeeded(
|
||||
variableDescriptor, property, delegatedType, trace, anonymousTypeTransformers, languageVersionSettings
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.contracts.EffectSystem
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
@@ -48,6 +47,8 @@ import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import java.util.*
|
||||
@@ -332,7 +333,7 @@ class CallCompleter(
|
||||
val typeConstructor = IntegerValueTypeConstructor(value, moduleDescriptor, constant.parameters)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
ErrorUtils.createErrorScope("Scope for number value type ($typeConstructor)", true)
|
||||
ErrorUtils.createErrorScope(ErrorScopeKind.INTEGER_LITERAL_TYPE_SCOPE, throwExceptions = true, typeConstructor.toString())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,19 +45,17 @@ import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
import org.jetbrains.kotlin.types.TypeRefinement
|
||||
import javax.inject.Inject
|
||||
|
||||
class CallExpressionResolver(
|
||||
@@ -276,7 +274,7 @@ class CallExpressionResolver(
|
||||
context.trace.report(
|
||||
FUNCTION_EXPECTED.on(
|
||||
calleeExpression, calleeExpression,
|
||||
type ?: ErrorUtils.createErrorType("")
|
||||
type ?: ErrorUtils.createErrorType(ErrorTypeKind.ERROR_EXPECTED_TYPE)
|
||||
)
|
||||
)
|
||||
argumentTypeResolver.analyzeArgumentsAndRecordTypes(
|
||||
@@ -456,7 +454,8 @@ class CallExpressionResolver(
|
||||
for (element in elementChain) {
|
||||
val receiverType = receiverTypeInfo.type
|
||||
?: ErrorUtils.createErrorType(
|
||||
"Type for " + when (val receiver = element.receiver) {
|
||||
ErrorTypeKind.ERROR_RECEIVER_TYPE,
|
||||
when (val receiver = element.receiver) {
|
||||
is KtNameReferenceExpression -> receiver.getReferencedName()
|
||||
else -> receiver.text
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.TypeUtils.noExpectedType
|
||||
import org.jetbrains.kotlin.types.checker.ErrorTypesAreEqualToAnything
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.typeUtil.containsTypeProjectionsInTopLevelArguments
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
@@ -110,15 +112,16 @@ class CandidateResolver(
|
||||
val typeArguments = ArrayList<KotlinType>()
|
||||
for (projection in ktTypeArguments) {
|
||||
val type = projection.typeReference?.let { trace.bindingContext.get(BindingContext.TYPE, it) }
|
||||
?: ErrorUtils.createErrorType("Star projection in a call")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.STAR_PROJECTION_IN_CALL)
|
||||
typeArguments.add(type)
|
||||
}
|
||||
|
||||
val expectedTypeArgumentCount = candidateDescriptor.typeParameters.size
|
||||
for (index in ktTypeArguments.size..expectedTypeArgumentCount - 1) {
|
||||
for (index in ktTypeArguments.size until expectedTypeArgumentCount) {
|
||||
typeArguments.add(
|
||||
ErrorUtils.createErrorType(
|
||||
"Explicit type argument expected for " + candidateDescriptor.typeParameters[index].name
|
||||
ErrorTypeKind.MISSED_TYPE_ARGUMENT_FOR_TYPE_PARAMETER,
|
||||
candidateDescriptor.typeParameters[index].name.toString()
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -370,7 +373,7 @@ class CandidateResolver(
|
||||
} else {
|
||||
resultingType = smartCast
|
||||
}
|
||||
} else if (ErrorUtils.containsUninferredParameter(expectedType)) {
|
||||
} else if (ErrorUtils.containsUninferredTypeVariable(expectedType)) {
|
||||
matchStatus = ArgumentMatchStatus.MATCH_MODULO_UNINFERRED_TYPES
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.intersectWrappedTypes
|
||||
@@ -656,7 +656,7 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
}
|
||||
|
||||
private fun KotlinType.containsUninferredTypeParameter(uninferredTypeVariable: TypeVariableMarker) = contains {
|
||||
ErrorUtils.isUninferredParameter(it) || it == TypeUtils.DONT_CARE
|
||||
ErrorUtils.isUninferredTypeVariable(it) || it == TypeUtils.DONT_CARE
|
||||
|| it.constructor == uninferredTypeVariable.freshTypeConstructor(typeSystemContext)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
class InfixCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
|
||||
class OperatorCallChecker : CallChecker {
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.results.SimpleConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasExactAnnotation
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasNoInferAnnotation
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
|
||||
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
|
||||
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure
|
||||
@@ -186,7 +187,7 @@ open class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystem
|
||||
}
|
||||
|
||||
private fun isErrorOrSpecialType(type: KotlinType?, constraintPosition: ConstraintPosition): Boolean {
|
||||
if (TypeUtils.isDontCarePlaceholder(type) || ErrorUtils.isUninferredParameter(type)) {
|
||||
if (TypeUtils.isDontCarePlaceholder(type) || ErrorUtils.isUninferredTypeVariable(type)) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -27,8 +27,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.derivedFr
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasInternalAnnotationForResolve
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isInternalAnnotationForResolve
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import java.util.*
|
||||
|
||||
@@ -135,10 +137,12 @@ internal class ConstraintSystemImpl(
|
||||
}
|
||||
|
||||
override val resultingSubstitutor: TypeSubstitutor
|
||||
get() = getSubstitutor(substituteOriginal = true) { ErrorUtils.createUninferredParameterType(it.originalTypeParameter) }
|
||||
get() = getSubstitutor(substituteOriginal = true) {
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_TYPE_VARIABLE, it.originalTypeParameter.name.asString())
|
||||
}
|
||||
|
||||
override val currentSubstitutor: TypeSubstitutor
|
||||
get() = getSubstitutor(substituteOriginal = true) { TypeUtils.DONT_CARE }
|
||||
get() = getSubstitutor(substituteOriginal = true) { DONT_CARE }
|
||||
|
||||
private fun getSubstitutor(substituteOriginal: Boolean, getDefaultValue: (TypeVariable) -> KotlinType): TypeSubstitutor {
|
||||
val parameterToInferredValueMap = getParameterToInferredValueMap(allTypeParameterBounds, getDefaultValue, substituteOriginal)
|
||||
@@ -152,7 +156,9 @@ internal class ConstraintSystemImpl(
|
||||
}
|
||||
|
||||
private fun satisfyInitialConstraints(): Boolean {
|
||||
val substitutor = getSubstitutor(substituteOriginal = false) { ErrorUtils.createUninferredParameterType(it.originalTypeParameter) }
|
||||
val substitutor = getSubstitutor(substituteOriginal = false) {
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_TYPE_VARIABLE, it.originalTypeParameter.name.asString())
|
||||
}
|
||||
fun KotlinType.substitute(): KotlinType? = substitutor.substitute(this, Variance.INVARIANT)
|
||||
|
||||
return initialConstraints.all { (kind, subtype, superType, position) ->
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.model
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
interface ArgumentMapping {
|
||||
fun isError(): Boolean
|
||||
|
||||
+3
-2
@@ -17,7 +17,8 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.smartcasts
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
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.TypeUtils
|
||||
|
||||
@@ -122,6 +123,6 @@ class DataFlowValue(
|
||||
fun nullValue(builtIns: KotlinBuiltIns) = DataFlowValue(IdentifierInfo.NULL, builtIns.nullableNothingType, Nullability.NULL)
|
||||
|
||||
@JvmField
|
||||
val ERROR = DataFlowValue(IdentifierInfo.ERROR, ErrorUtils.createErrorType("Error type for data flow"), Nullability.IMPOSSIBLE)
|
||||
val ERROR = DataFlowValue(IdentifierInfo.ERROR, ErrorUtils.createErrorType(ErrorTypeKind.ERROR_DATA_FLOW_TYPE), Nullability.IMPOSSIBLE)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.util.CallResolverUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -224,7 +224,7 @@ class DynamicCallableDescriptors(private val storageManager: StorageManager, bui
|
||||
for (funLiteralArg in call.functionLiteralArguments) {
|
||||
addParameter(
|
||||
funLiteralArg,
|
||||
funLiteralArg.getLambdaExpression()?.let { getFunctionType(it) } ?: TypeUtils.CANT_INFER_FUNCTION_PARAM_TYPE,
|
||||
funLiteralArg.getLambdaExpression()?.let { getFunctionType(it) } ?: TypeUtils.CANNOT_INFER_FUNCTION_PARAM_TYPE,
|
||||
null)
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.extensions.internal.CandidateInterceptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -37,6 +36,8 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
@@ -396,7 +397,7 @@ class KotlinToResolvedCallTransformer(
|
||||
val typeConstructor = IntegerLiteralTypeConstructor(value, moduleDescriptor, constant.parameters)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
ErrorUtils.createErrorScope("Scope for number value type ($typeConstructor)", true),
|
||||
ErrorUtils.createErrorScope(ErrorScopeKind.INTEGER_LITERAL_TYPE_SCOPE, throwExceptions = true, typeConstructor.toString()),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
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.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
@@ -71,7 +72,7 @@ class ParseErrorKotlinCallArgument(
|
||||
override val dataFlowInfoAfterThisArgument: DataFlowInfo,
|
||||
) : ExpressionKotlinCallArgument, SimplePSIKotlinCallArgument() {
|
||||
override val receiver = ReceiverValueWithSmartCastInfo(
|
||||
TransientReceiver(ErrorUtils.createErrorType("Error type for ParseError-argument $valueArgument")),
|
||||
TransientReceiver(ErrorUtils.createErrorType(ErrorTypeKind.PARSE_ERROR_ARGUMENT, valueArgument.toString())),
|
||||
typesFromSmartCasts = emptySet(),
|
||||
isStable = true
|
||||
)
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.canBeResolvedWithoutDeprecation
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeApproximator
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
|
||||
@@ -43,8 +43,10 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import org.jetbrains.kotlin.util.buildNotFixedVariablesToPossibleResultType
|
||||
@@ -58,8 +60,9 @@ enum class ResolveArgumentsMode {
|
||||
|
||||
fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
|
||||
assert(ReflectionTypes.isCallableType(type) || type.isSuspendFunctionType) { "type $type is not a function or property" }
|
||||
return getParameterArgumentsOfCallableType(type).any {
|
||||
it.type.contains { TypeUtils.isDontCarePlaceholder(it) } || ErrorUtils.containsUninferredParameter(it.type)
|
||||
return getParameterArgumentsOfCallableType(type).any { typeProjection ->
|
||||
typeProjection.type.contains { TypeUtils.isDontCarePlaceholder(it) }
|
||||
|| ErrorUtils.containsUninferredTypeVariable(typeProjection.type)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +139,7 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
|
||||
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
receiverType.attributes, receiverTypeConstructor, fakeTypeArguments,
|
||||
receiverType.isMarkedNullable, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)
|
||||
receiverType.isMarkedNullable, ErrorUtils.createErrorScope(ErrorScopeKind.ERASED_RECEIVER_TYPE_SCOPE, throwExceptions = true)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
|
||||
@@ -117,7 +118,7 @@ fun ResolvedCall<*>.hasInferredReturnType(): Boolean {
|
||||
if (isNewNotCompleted()) return false
|
||||
|
||||
val returnType = this.resultingDescriptor.returnType ?: return false
|
||||
return !returnType.contains { ErrorUtils.isUninferredParameter(it) }
|
||||
return !returnType.contains { ErrorUtils.isUninferredTypeVariable(it) }
|
||||
}
|
||||
|
||||
fun CandidateApplicability.toResolutionStatus(): ResolutionStatus = when (this) {
|
||||
|
||||
+3
-2
@@ -35,7 +35,8 @@ import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
import org.jetbrains.kotlin.types.AbbreviatedType
|
||||
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.typeUtil.replaceAnnotations
|
||||
|
||||
abstract class LazyAnnotationsContext(
|
||||
@@ -97,7 +98,7 @@ class LazyAnnotationDescriptor(
|
||||
annotationType
|
||||
},
|
||||
onRecursiveCall = {
|
||||
ErrorUtils.createErrorType("Recursion in type of annotation detected")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.RECURSIVE_ANNOTATION_TYPE)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
import org.jetbrains.kotlin.utils.DFS;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -112,7 +114,7 @@ public class CommonSupertypes {
|
||||
iterator.remove();
|
||||
}
|
||||
if (KotlinTypeKt.isError(type)) {
|
||||
return ErrorUtils.createErrorType("Supertype of error type " + type);
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.SUPER_TYPE_FOR_ERROR_TYPE, type.toString());
|
||||
}
|
||||
nullable |= type.isMarkedNullable();
|
||||
}
|
||||
@@ -270,7 +272,7 @@ public class CommonSupertypes {
|
||||
newScope = classifier.getDefaultType().getMemberScope();
|
||||
}
|
||||
else {
|
||||
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
||||
newScope = ErrorUtils.createErrorScope(ErrorScopeKind.NON_CLASSIFIER_SUPER_TYPE_SCOPE, true);
|
||||
}
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(TypeAttributes.Companion.getEmpty(), constructor, newProjections, nullable, newScope);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.util.Box;
|
||||
import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException;
|
||||
|
||||
@@ -31,7 +33,7 @@ import static org.jetbrains.kotlin.resolve.BindingContext.DEFERRED_TYPE;
|
||||
public class DeferredType extends WrappedType {
|
||||
private static final Function1<Boolean, KotlinType> RECURSION_PREVENTER = firstTime -> {
|
||||
if (firstTime) throw new ReenteringLazyValueComputationException();
|
||||
return ErrorUtils.createErrorType("Recursive dependency");
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.RECURSIVE_TYPE);
|
||||
};
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.jetbrains.kotlin.resolve.calls.inference.CallHandle;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -68,7 +70,7 @@ public class TypeIntersector {
|
||||
|
||||
if (nullabilityStripped.isEmpty()) {
|
||||
// All types were errors
|
||||
return ErrorUtils.createErrorType("Intersection of error types: " + types);
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.INTERSECTION_OF_ERROR_TYPES, types.toString());
|
||||
}
|
||||
|
||||
KotlinTypeChecker typeChecker = KotlinTypeChecker.DEFAULT;
|
||||
|
||||
+4
-2
@@ -74,6 +74,8 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils.ResolveConstruct;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.types.expressions.unqualifiedSuper.UnqualifiedSuperKt;
|
||||
@@ -792,7 +794,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (operationType == KtTokens.PLUSPLUS || operationType == KtTokens.MINUSMINUS) {
|
||||
assert returnType != null : "returnType is null for " + resolutionResults.getResultingDescriptor();
|
||||
if (KotlinBuiltIns.isUnit(returnType)) {
|
||||
result = ErrorUtils.createErrorType(components.builtIns.getUnit().getName().asString());
|
||||
result = ErrorUtils.createErrorType(ErrorTypeKind.UNIT_RETURN_TYPE_FOR_INC_DEC);
|
||||
context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign));
|
||||
}
|
||||
else {
|
||||
@@ -920,7 +922,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
) {
|
||||
if (ktType == null) return false;
|
||||
|
||||
if (KotlinTypeKt.isError(ktType) && !ErrorUtils.isUninferredParameter(ktType)) return false;
|
||||
if (KotlinTypeKt.isError(ktType) && !ErrorUtils.isUninferredTypeVariable(ktType)) return false;
|
||||
|
||||
if (!TypeUtils.isNullableType(ktType)) return true;
|
||||
|
||||
|
||||
+8
-12
@@ -37,11 +37,10 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.SuspendFunctionTypeUtilKt;
|
||||
import org.jetbrains.kotlin.types.CommonSupertypes;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils.ResolveConstruct;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
|
||||
@@ -60,9 +59,6 @@ import static org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.ge
|
||||
import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.*;
|
||||
|
||||
public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
private static final String RETURN_NOT_ALLOWED_MESSAGE = "Return not allowed";
|
||||
|
||||
protected ControlStructureTypingVisitor(@NotNull ExpressionTypingInternals facade) {
|
||||
super(facade);
|
||||
}
|
||||
@@ -433,7 +429,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
loopScope.addVariableDescriptor(variableDescriptor);
|
||||
KtDestructuringDeclaration multiParameter = loopParameter.getDestructuringDeclaration();
|
||||
if (multiParameter != null) {
|
||||
KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType;
|
||||
KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType(ErrorTypeKind.NO_TYPE_FOR_LOOP_RANGE) : expectedParameterType;
|
||||
TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType);
|
||||
components.annotationResolver.resolveAnnotationsWithArguments(loopScope, loopParameter.getModifierList(), context.trace);
|
||||
components.destructuringDeclarationResolver.defineLocalVariablesFromDestructuringDeclaration(
|
||||
@@ -479,7 +475,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
else {
|
||||
if (expectedParameterType == null) {
|
||||
expectedParameterType = ErrorUtils.createErrorType("Error");
|
||||
expectedParameterType = ErrorUtils.createErrorType(ErrorTypeKind.NO_TYPE_FOR_LOOP_PARAMETER);
|
||||
}
|
||||
variableDescriptor = components.descriptorResolver.
|
||||
resolveLocalVariableDescriptor(loopParameter, expectedParameterType, context.trace, context.scope);
|
||||
@@ -852,7 +848,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
isClassInitializer(containingFunInfo)) {
|
||||
// Unqualified, in a function literal
|
||||
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
|
||||
resultType = ErrorUtils.createErrorType(ErrorTypeKind.RETURN_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
expectedType = getFunctionExpectedReturnType(containingFunctionDescriptor, (KtElement) containingFunInfo.getSecond(), context);
|
||||
@@ -861,7 +857,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
else {
|
||||
// Outside a function
|
||||
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
|
||||
resultType = ErrorUtils.createErrorType(ErrorTypeKind.RETURN_NOT_ALLOWED);
|
||||
}
|
||||
}
|
||||
else if (labelTargetElement != null) {
|
||||
@@ -872,7 +868,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (!InlineUtil.checkNonLocalReturnUsage(functionDescriptor, expression, context)) {
|
||||
// Qualified, non-local
|
||||
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
|
||||
resultType = ErrorUtils.createErrorType(ErrorTypeKind.RETURN_NOT_ALLOWED);
|
||||
}
|
||||
else if (labelTargetElement instanceof KtFunctionLiteral
|
||||
&& Objects.equals(expression.getLabelName(), "suspend")) {
|
||||
|
||||
+3
-2
@@ -31,7 +31,8 @@ import org.jetbrains.kotlin.resolve.checkers.TrailingCommaChecker
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
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.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
@@ -93,7 +94,7 @@ class DestructuringDeclarationResolver(
|
||||
receiver: ReceiverValue?,
|
||||
initializer: KtExpression?
|
||||
): KotlinType {
|
||||
fun errorType() = ErrorUtils.createErrorType("$componentName() return type")
|
||||
fun errorType() = ErrorUtils.createErrorType(ErrorTypeKind.ERROR_TYPE_FOR_DESTRUCTURING_COMPONENT, componentName.toString())
|
||||
|
||||
if (receiver == null) return errorType()
|
||||
|
||||
|
||||
+5
-3
@@ -40,8 +40,10 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.expressions.FunctionWithBigAritySupport.LanguageVersionDependent
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||
@@ -127,7 +129,7 @@ class DoubleColonExpressionResolver(
|
||||
}
|
||||
}
|
||||
|
||||
return createTypeInfo(ErrorUtils.createErrorType("Unresolved class"), c)
|
||||
return createTypeInfo(ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_CLASS_TYPE, expression.toString()), c)
|
||||
}
|
||||
|
||||
private fun checkClassLiteral(
|
||||
@@ -479,7 +481,7 @@ class DoubleColonExpressionResolver(
|
||||
val classifier = qualifierResolutionResult.classifierDescriptor
|
||||
if (classifier == null) {
|
||||
typeResolver.resolveTypeProjections(
|
||||
typeResolutionContext, ErrorUtils.createErrorType("No type").constructor, qualifierResolutionResult.allProjections
|
||||
typeResolutionContext, ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, expression.text).constructor, qualifierResolutionResult.allProjections
|
||||
)
|
||||
return null
|
||||
}
|
||||
@@ -534,7 +536,7 @@ class DoubleColonExpressionResolver(
|
||||
if (callableReference.getReferencedName().isEmpty()) {
|
||||
if (!expression.isEmptyLHS) resolveDoubleColonLHS(expression, c)
|
||||
c.trace.report(UNRESOLVED_REFERENCE.on(callableReference, callableReference))
|
||||
val errorType = ErrorUtils.createErrorType("Empty callable reference")
|
||||
val errorType = ErrorUtils.createErrorType(ErrorTypeKind.EMPTY_CALLABLE_REFERENCE)
|
||||
return dataFlowAnalyzer.createCheckedTypeInfo(errorType, c, expression)
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -28,7 +28,8 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionCallbacksImpl;
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.LambdaContextInfo;
|
||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||
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.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
@@ -79,7 +80,7 @@ public class ExpressionTypingServices {
|
||||
) {
|
||||
KotlinType type = getType(scope, expression, expectedType, dataFlowInfo, inferenceSession, trace);
|
||||
|
||||
return type != null ? type : ErrorUtils.createErrorType("Type for " + expression.getText());
|
||||
return type != null ? type : ErrorUtils.createErrorType(ErrorTypeKind.NO_RECORDED_TYPE, expression.getText());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -244,7 +245,7 @@ public class ExpressionTypingServices {
|
||||
return type;
|
||||
}
|
||||
else {
|
||||
return ErrorUtils.createErrorType("Error function type");
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE_FOR_FUNCTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -25,7 +25,8 @@ import org.jetbrains.kotlin.resolve.calls.context.CallPosition;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||
import org.jetbrains.kotlin.types.DeferredType;
|
||||
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.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.util.KotlinFrontEndException;
|
||||
@@ -124,7 +125,7 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<Kotlin
|
||||
return typeInfo;
|
||||
}
|
||||
return typeInfo
|
||||
.replaceType(ErrorUtils.createErrorType("Type for " + expression.getText()))
|
||||
.replaceType(ErrorUtils.createErrorType(ErrorTypeKind.NO_RECORDED_TYPE, expression.getText()))
|
||||
.replaceDataFlowInfo(context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<Kotlin
|
||||
context.trace.report(Errors.EXCEPTION_FROM_ANALYZER.on(expression, e));
|
||||
logOrThrowException(expression, e);
|
||||
return TypeInfoFactoryKt.createTypeInfo(
|
||||
ErrorUtils.createErrorType(e.getClass().getSimpleName() + " from analyzer"),
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.TYPE_FOR_COMPILER_EXCEPTION, e.getClass().getSimpleName()),
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.DynamicTypesKt;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
+1
-1
@@ -243,7 +243,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
return components.builtIns.unitType
|
||||
}
|
||||
}
|
||||
return returnType ?: CANT_INFER_FUNCTION_PARAM_TYPE
|
||||
return returnType ?: CANNOT_INFER_FUNCTION_PARAM_TYPE
|
||||
}
|
||||
|
||||
private fun computeUnsafeReturnType(
|
||||
|
||||
+3
-1
@@ -37,8 +37,10 @@ import org.jetbrains.kotlin.resolve.checkers.PrimitiveNumericComparisonCallCheck
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils.*
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||
@@ -92,7 +94,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
|
||||
val element: KtElement?,
|
||||
val typeInfo: KotlinTypeInfo?,
|
||||
val scopeWithSubject: LexicalScope?,
|
||||
val type: KotlinType = typeInfo?.type ?: ErrorUtils.createErrorType("Unknown type")
|
||||
val type: KotlinType = typeInfo?.type ?: ErrorUtils.createErrorType(ErrorTypeKind.UNKNOWN_TYPE)
|
||||
) {
|
||||
|
||||
protected abstract fun createDataFlowValue(contextAfterSubject: ExpressionTypingContext, builtIns: KotlinBuiltIns): DataFlowValue
|
||||
|
||||
+4
-5
@@ -24,10 +24,9 @@ import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.PossiblyBareType;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeReconstructionResult;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.NO_TYPE_ARGUMENTS_ON_RHS;
|
||||
|
||||
@@ -60,7 +59,7 @@ public class TypeReconstructionUtil {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
return ErrorUtils.createErrorType("Failed to reconstruct type: " + right.getText());
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.ERROR_WHILE_RECONSTRUCTING_BARE_TYPE, right.getText());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-3
@@ -22,7 +22,8 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
class ErrorExpressionGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) {
|
||||
private val ignoreErrors: Boolean get() = context.configuration.ignoreErrors
|
||||
@@ -39,7 +40,7 @@ class ErrorExpressionGenerator(statementGenerator: StatementGenerator) : Stateme
|
||||
if (ktElement is KtExpression)
|
||||
getErrorExpressionType(ktElement)
|
||||
else
|
||||
ErrorUtils.createErrorType("")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.TYPE_FOR_GENERATED_ERROR_EXPRESSION)
|
||||
IrErrorExpressionImpl(
|
||||
ktElement.startOffsetSkippingComments, ktElement.endOffset,
|
||||
errorExpressionType.toIrType(),
|
||||
@@ -66,7 +67,7 @@ class ErrorExpressionGenerator(statementGenerator: StatementGenerator) : Stateme
|
||||
}
|
||||
|
||||
private fun getErrorExpressionType(ktExpression: KtExpression) =
|
||||
getTypeInferredByFrontend(ktExpression) ?: ErrorUtils.createErrorType("")
|
||||
getTypeInferredByFrontend(ktExpression) ?: ErrorUtils.createErrorType(ErrorTypeKind.ERROR_EXPRESSION_TYPE)
|
||||
|
||||
fun generateErrorSimpleName(ktName: KtSimpleNameExpression): IrExpression = generateErrorExpression(ktName) {
|
||||
val type = getErrorExpressionType(ktName).toIrType()
|
||||
|
||||
@@ -422,7 +422,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
TODO("IrTypeSystemContext doesn't support constraint system resolution")
|
||||
}
|
||||
|
||||
override fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker =
|
||||
override fun createUninferredType(constructor: TypeConstructorMarker): KotlinTypeMarker =
|
||||
TODO("IrTypeSystemContext doesn't support constraint system resolution")
|
||||
|
||||
override fun nullableAnyType() = irBuiltIns.anyNType as IrSimpleType
|
||||
|
||||
+9
-6
@@ -8,25 +8,28 @@ package org.jetbrains.kotlin.backend.common.serialization.metadata
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DYNAMIC_TYPE_DESERIALIZER_ID
|
||||
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeDeserializer
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker
|
||||
import org.jetbrains.kotlin.types.createDynamicType
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
object DynamicTypeDeserializer : FlexibleTypeDeserializer {
|
||||
const val id = DYNAMIC_TYPE_DESERIALIZER_ID
|
||||
|
||||
override fun create(proto: ProtoBuf.Type, flexibleId: String, lowerBound: SimpleType, upperBound: SimpleType): KotlinType {
|
||||
if (flexibleId != id) return ErrorUtils.createErrorType("Unexpected id: $flexibleId. ($lowerBound..$upperBound)")
|
||||
if (flexibleId != id) {
|
||||
return ErrorUtils.createErrorType(
|
||||
ErrorTypeKind.UNEXPECTED_FLEXIBLE_TYPE_ID, flexibleId, lowerBound.toString(), upperBound.toString()
|
||||
)
|
||||
}
|
||||
|
||||
return if (StrictEqualityTypeChecker.strictEqualTypes(lowerBound, lowerBound.builtIns.nothingType) &&
|
||||
StrictEqualityTypeChecker.strictEqualTypes(upperBound, upperBound.builtIns.nullableAnyType)
|
||||
) {
|
||||
createDynamicType(lowerBound.builtIns)
|
||||
} else {
|
||||
ErrorUtils.createErrorType("Illegal type range for dynamic type: $lowerBound..$upperBound")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.ILLEGAL_TYPE_RANGE_FOR_DYNAMIC, lowerBound.toString(), upperBound.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -27,8 +27,7 @@ fun ConstraintStorage.buildAbstractResultingSubstitutor(
|
||||
}
|
||||
val uninferredSubstitutorMap = if (transformTypeVariablesToErrorTypes) {
|
||||
notFixedTypeVariables.entries.associate { (freshTypeConstructor, typeVariable) ->
|
||||
freshTypeConstructor to context.createErrorTypeWithCustomConstructor(
|
||||
"Uninferred type",
|
||||
freshTypeConstructor to context.createUninferredType(
|
||||
(typeVariable.typeVariable).freshTypeConstructor()
|
||||
)
|
||||
}
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.captureFromExpression
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
|
||||
import org.jetbrains.kotlin.types.model.TypeVariance
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.ExpectedTypeConstraint
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.forceResolution
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.model.safeSubstitute
|
||||
|
||||
+5
-8
@@ -22,12 +22,9 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.model.TypeVariance
|
||||
import org.jetbrains.kotlin.types.model.convertVariance
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -119,7 +116,7 @@ private fun extraLambdaInfo(
|
||||
contextReceiverType
|
||||
} else {
|
||||
diagnosticsHolder.addDiagnostic(NotEnoughInformationForLambdaParameter(argument, index))
|
||||
ErrorUtils.createErrorType("<Unknown lambda context receiver type>")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_LAMBDA_CONTEXT_RECEIVER_TYPE)
|
||||
}
|
||||
} ?: emptyList()
|
||||
val parameters = argument.parametersTypes?.mapIndexed { index, parameterType ->
|
||||
@@ -127,7 +124,7 @@ private fun extraLambdaInfo(
|
||||
parameterType
|
||||
} else {
|
||||
diagnosticsHolder.addDiagnostic(NotEnoughInformationForLambdaParameter(argument, index))
|
||||
ErrorUtils.createErrorType("<Unknown lambda parameter type>")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_LAMBDA_PARAMETER_TYPE)
|
||||
}
|
||||
} ?: emptyList()
|
||||
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.typeConstructor
|
||||
|
||||
+5
-3
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.resolve.calls.components.transformToResolvedLambda
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||
import org.jetbrains.kotlin.types.model.safeSubstitute
|
||||
@@ -327,15 +329,15 @@ class KotlinConstraintSystemCompleter(
|
||||
|
||||
val resultErrorType = when {
|
||||
typeVariable is TypeVariableFromCallableDescriptor -> {
|
||||
ErrorUtils.createUninferredParameterType(typeVariable.originalTypeParameter)
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_TYPE_VARIABLE, typeVariable.originalTypeParameter.name.asString())
|
||||
}
|
||||
typeVariable is TypeVariableForLambdaParameterType && typeVariable.atom is LambdaKotlinCallArgument -> {
|
||||
diagnosticsHolder.addDiagnostic(
|
||||
NotEnoughInformationForLambdaParameter(typeVariable.atom, typeVariable.index)
|
||||
)
|
||||
ErrorUtils.createErrorType("Cannot infer lambda parameter type")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_LAMBDA_PARAMETER_TYPE)
|
||||
}
|
||||
else -> ErrorUtils.createErrorType("Cannot infer type variable $typeVariable")
|
||||
else -> ErrorUtils.createErrorType(ErrorTypeKind.UNINFERRED_TYPE_VARIABLE, typeVariable.toString())
|
||||
}
|
||||
|
||||
fixVariable(typeVariable, resultErrorType, FixVariableConstraintPositionImpl(typeVariable, resolvedAtom))
|
||||
|
||||
+3
-1
@@ -10,9 +10,11 @@ import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableFromCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor
|
||||
import org.jetbrains.kotlin.types.checker.intersectTypes
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker
|
||||
|
||||
interface NewTypeSubstitutor : TypeSubstitutorMarker {
|
||||
@@ -185,7 +187,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
|
||||
val arguments = type.arguments
|
||||
if (parameters.size != arguments.size) {
|
||||
// todo error type or exception?
|
||||
return ErrorUtils.createErrorType("Inconsistent type: $type (parameters.size = ${parameters.size}, arguments.size = ${arguments.size})")
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.TYPE_WITH_MISMATCHED_TYPE_ARGUMENTS_AND_PARAMETERS, type.toString(), parameters.size.toString(), arguments.size.toString())
|
||||
}
|
||||
val newArguments = arrayOfNulls<TypeProjection?>(arguments.size)
|
||||
|
||||
|
||||
+6
-3
@@ -24,6 +24,9 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
@@ -41,7 +44,7 @@ class CallableReferencesCandidateFactory(
|
||||
get() = receiver.receiverValue
|
||||
|
||||
override fun createErrorCandidate(): CallableReferenceResolutionCandidate {
|
||||
val errorScope = ErrorUtils.createErrorScope("Error resolution candidate for call $kotlinCall")
|
||||
val errorScope = ErrorUtils.createErrorScope(ErrorScopeKind.SCOPE_FOR_ERROR_RESOLUTION_CANDIDATE, kotlinCall.toString())
|
||||
val errorDescriptor = errorScope.getContributedFunctions(kotlinCall.rhsName, scopeTower.location).first()
|
||||
|
||||
val (reflectionCandidateType, callableReferenceAdaptation) = buildReflectionType(
|
||||
@@ -346,7 +349,7 @@ class CallableReferencesCandidateFactory(
|
||||
}
|
||||
|
||||
val descriptorReturnType = descriptor.returnType
|
||||
?: ErrorUtils.createErrorType("Error return type for descriptor: $descriptor")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE, descriptor.toString())
|
||||
|
||||
return when (descriptor) {
|
||||
is PropertyDescriptor -> {
|
||||
@@ -397,7 +400,7 @@ class CallableReferencesCandidateFactory(
|
||||
}
|
||||
else -> {
|
||||
assert(!descriptor.isSupportedForCallableReference()) { "${descriptor::class} isn't supported to use in callable references actually, but it's listed in `isSupportedForCallableReference` method" }
|
||||
ErrorUtils.createErrorType("Unsupported descriptor type: $descriptor") to null
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNSUPPORTED_CALLABLE_REFERENCE_TYPE, descriptor.toString()) to null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.model
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
||||
import org.jetbrains.kotlin.resolve.calls.components.NewConstraintSystemImpl
|
||||
@@ -18,8 +17,9 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDynamicExtensionAnnotation
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
|
||||
class SimpleCandidateFactory(
|
||||
@@ -161,7 +161,7 @@ class SimpleCandidateFactory(
|
||||
}
|
||||
|
||||
override fun createErrorCandidate(): SimpleResolutionCandidate {
|
||||
val errorScope = ErrorUtils.createErrorScope("Error resolution candidate for call $kotlinCall")
|
||||
val errorScope = ErrorUtils.createErrorScope(ErrorScopeKind.SCOPE_FOR_ERROR_RESOLUTION_CANDIDATE, kotlinCall.toString())
|
||||
val errorDescriptor = if (kotlinCall.callKind == KotlinCallKind.VARIABLE) {
|
||||
errorScope.getContributedVariables(kotlinCall.name, scopeTower.location)
|
||||
} else {
|
||||
|
||||
@@ -36,6 +36,9 @@ import org.jetbrains.kotlin.resolve.scopes.utils.collectFunctions
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectVariables
|
||||
import org.jetbrains.kotlin.resolve.selectMostSpecificInEachOverridableGroup
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorScope
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ThrowingScope
|
||||
import org.jetbrains.kotlin.types.typeUtil.getImmediateSuperclassNotAny
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
@@ -92,8 +95,9 @@ internal class MemberScopeTowerLevel(
|
||||
getMembers: ResolutionScope.(KotlinType?) -> Collection<CallableDescriptor>
|
||||
): Collection<CandidateWithBoundDispatchReceiver> {
|
||||
val receiverValue = dispatchReceiver.receiverValue
|
||||
val memberScope = receiverValue.type.memberScope
|
||||
|
||||
if (receiverValue.type is AbstractStubType && receiverValue.type.memberScope is ErrorUtils.ErrorScope) {
|
||||
if (receiverValue.type is AbstractStubType && memberScope is ErrorScope && memberScope !is ThrowingScope) {
|
||||
return arrayListOf()
|
||||
}
|
||||
|
||||
@@ -215,7 +219,8 @@ internal class ContextReceiversGroupScopeTowerLevel(
|
||||
|
||||
for (contextReceiver in contextReceiversGroup) {
|
||||
val receiverValue = contextReceiver.receiverValue
|
||||
if (receiverValue.type is AbstractStubType && receiverValue.type.memberScope is ErrorUtils.ErrorScope) {
|
||||
val memberScope = receiverValue.type.memberScope
|
||||
if (receiverValue.type is AbstractStubType && memberScope is ErrorScope && memberScope !is ThrowingScope) {
|
||||
return arrayListOf()
|
||||
}
|
||||
receiverValue.type.memberScope.getMembers(receiverValue.type).mapTo(result) {
|
||||
|
||||
@@ -21,7 +21,9 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorClassDescriptor
|
||||
import org.jetbrains.kotlin.types.error.ErrorEntity
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.util.collectionUtils.concat
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
@@ -303,7 +305,7 @@ class ErrorLexicalScope : LexicalScope {
|
||||
override val parent: HierarchicalScope? = null
|
||||
|
||||
override fun printStructure(p: Printer) {
|
||||
p.print("<FAKE PARENT FOR ERROR LEXICAL SCOPE>")
|
||||
p.print(ErrorEntity.PARENT_OF_ERROR_SCOPE.debugText)
|
||||
}
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
|
||||
@@ -319,10 +321,11 @@ class ErrorLexicalScope : LexicalScope {
|
||||
}
|
||||
|
||||
override fun printStructure(p: Printer) {
|
||||
p.print("<ERROR_SCOPE>")
|
||||
p.print(ErrorEntity.ERROR_SCOPE.debugText)
|
||||
}
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor = ErrorUtils.createErrorClass("<ERROR CLASS FOR ERROR SCOPE>")
|
||||
override val ownerDescriptor: DeclarationDescriptor =
|
||||
ErrorClassDescriptor(Name.special(ErrorEntity.ERROR_CLASS.debugText.format("unknown")))
|
||||
override val isOwnerDescriptorAccessibleByLabel: Boolean = false
|
||||
override val implicitReceiver: ReceiverParameterDescriptor? = null
|
||||
override val contextReceiversGroup: List<ReceiverParameterDescriptor> = emptyList()
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
open class AnnotationSerializer(private val stringTable: DescriptorAwareStringTable) {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.metadata.serialization.StringTable
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
interface DescriptorAwareStringTable : StringTable {
|
||||
fun getQualifiedClassNameIndex(classId: ClassId): Int =
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.tests.di.createContainerForTests
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import java.io.File
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ interface TypeSystemTypeFactoryContext: TypeSystemBuiltInsContext {
|
||||
fun createStarProjection(typeParameter: TypeParameterMarker): TypeArgumentMarker
|
||||
|
||||
fun createErrorType(debugName: String): SimpleTypeMarker
|
||||
fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker
|
||||
fun createUninferredType(constructor: TypeConstructorMarker): KotlinTypeMarker
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -34,7 +34,8 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
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.*
|
||||
|
||||
@@ -159,7 +160,7 @@ object JavaAnnotationTargetMapper {
|
||||
JavaAnnotationMapper.TARGET_ANNOTATION_ALLOWED_TARGETS,
|
||||
module.builtIns.getBuiltInClassByFqName(StandardNames.FqNames.target)
|
||||
)
|
||||
parameterDescriptor?.type ?: ErrorUtils.createErrorType("Error: AnnotationTarget[]")
|
||||
parameterDescriptor?.type ?: ErrorUtils.createErrorType(ErrorTypeKind.UNMAPPED_ANNOTATION_TARGET_TYPE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -33,7 +33,8 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
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.Variance
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
|
||||
@@ -47,7 +48,8 @@ class LazyJavaAnnotationDescriptor(
|
||||
}
|
||||
|
||||
override val type by c.storageManager.createLazyValue {
|
||||
val fqName = fqName ?: return@createLazyValue ErrorUtils.createErrorType("No fqName: $javaAnnotation")
|
||||
val fqName = fqName
|
||||
?: return@createLazyValue ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_FQNAME_FOR_JAVA_ANNOTATION, javaAnnotation.toString())
|
||||
val annotationClass = JavaToKotlinClassMapper.mapJavaToKotlin(fqName, c.module.builtIns)
|
||||
?: javaAnnotation.resolve()?.let { javaClass -> c.components.moduleClassResolver.resolveClass(javaClass) }
|
||||
?: createTypeForMissingDependencies(fqName)
|
||||
@@ -86,7 +88,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
// Try to load annotation arguments even if the annotation class is not found
|
||||
?: c.components.module.builtIns.getArrayType(
|
||||
Variance.INVARIANT,
|
||||
ErrorUtils.createErrorType("Unknown array element type")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.UNKNOWN_ARRAY_ELEMENT_TYPE_OF_ANNOTATION_ARGUMENT)
|
||||
)
|
||||
|
||||
val values = elements.map { argument ->
|
||||
|
||||
+6
-2
@@ -32,6 +32,8 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.*
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
@@ -92,7 +94,7 @@ class JavaTypeResolver(
|
||||
}
|
||||
|
||||
private fun transformJavaClassifierType(javaType: JavaClassifierType, attr: JavaTypeAttributes): KotlinType {
|
||||
fun errorType() = ErrorUtils.createErrorType("Unresolved java class ${javaType.presentableText}")
|
||||
fun errorType() = ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_JAVA_CLASS, javaType.presentableText)
|
||||
|
||||
val useFlexible = !attr.isForAnnotationParameter && attr.howThisTypeIsUsed != SUPERTYPE
|
||||
val isRaw = javaType.isRaw
|
||||
@@ -256,7 +258,9 @@ class JavaTypeResolver(
|
||||
|
||||
if (typeParameters.size != javaType.typeArguments.size) {
|
||||
// Most of the time this means there is an error in the Java code
|
||||
return typeParameters.map { p -> TypeProjectionImpl(ErrorUtils.createErrorType(p.name.asString())) }.toList()
|
||||
return typeParameters.map { p ->
|
||||
TypeProjectionImpl(ErrorUtils.createErrorType(ErrorTypeKind.MISSED_TYPE_ARGUMENT_FOR_TYPE_PARAMETER, p.name.asString()))
|
||||
}.toList()
|
||||
}
|
||||
return javaType.typeArguments.withIndex().map { indexedArgument ->
|
||||
val (i, javaTypeArgument) = indexedArgument
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.load.java.lazy.types
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions
|
||||
@@ -30,6 +29,8 @@ import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.TypeRefinement
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
class RawTypeImpl private constructor(lowerBound: SimpleType, upperBound: SimpleType, disableAssertion: Boolean) :
|
||||
@@ -149,7 +150,9 @@ internal class RawSubstitution(typeParameterUpperBoundEraser: TypeParameterUpper
|
||||
) to false
|
||||
}
|
||||
|
||||
if (type.isError) return ErrorUtils.createErrorType("Raw error type: ${type.constructor}") to false
|
||||
if (type.isError) {
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.ERROR_RAW_TYPE, type.constructor.toString()) to false
|
||||
}
|
||||
|
||||
val memberScope = declaration.getMemberScope(this)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
|
||||
+3
-1
@@ -9,6 +9,8 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.extractTypeParametersFromUpperBounds
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjectionOrMapped
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
||||
@@ -16,7 +18,7 @@ import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
||||
internal class TypeParameterUpperBoundEraser(rawSubstitution: RawSubstitution? = null) {
|
||||
private val storage = LockBasedStorageManager("Type parameter upper bound erasion results")
|
||||
private val erroneousErasedBound by lazy {
|
||||
ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`")
|
||||
ErrorUtils.createErrorType(ErrorTypeKind.CANNOT_COMPUTE_ERASED_BOUND, this.toString())
|
||||
}
|
||||
private val rawSubstitution = rawSubstitution ?: RawSubstitution(this)
|
||||
|
||||
|
||||
+4
-5
@@ -21,15 +21,14 @@ import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeDeserializer
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
|
||||
object JavaFlexibleTypeDeserializer : FlexibleTypeDeserializer {
|
||||
override fun create(proto: ProtoBuf.Type, flexibleId: String, lowerBound: SimpleType, upperBound: SimpleType): KotlinType {
|
||||
if (flexibleId != JvmProtoBufUtil.PLATFORM_TYPE_ID) {
|
||||
return ErrorUtils.createErrorType("Error java flexible type with id: $flexibleId. ($lowerBound..$upperBound)")
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.ERROR_FLEXIBLE_TYPE, flexibleId, lowerBound.toString(), upperBound.toString())
|
||||
}
|
||||
if (proto.hasExtension(JvmProtoBuf.isRaw)) {
|
||||
return RawTypeImpl(lowerBound, upperBound)
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
||||
|
||||
@@ -18,12 +18,13 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
private val FAKE_CONTINUATION_CLASS_DESCRIPTOR =
|
||||
MutableClassDescriptor(
|
||||
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), COROUTINES_PACKAGE_FQ_NAME),
|
||||
EmptyPackageFragmentDescriptor(ErrorUtils.errorModule, COROUTINES_PACKAGE_FQ_NAME),
|
||||
ClassKind.INTERFACE, /* isInner = */ false, /* isExternal = */ false,
|
||||
CONTINUATION_INTERFACE_FQ_NAME.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
|
||||
).apply {
|
||||
|
||||
@@ -37,7 +37,7 @@ interface ModuleDescriptor : DeclarationDescriptor {
|
||||
|
||||
fun shouldSeeInternalsOf(targetModule: ModuleDescriptor): Boolean
|
||||
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R? {
|
||||
return visitor.visitModuleDeclaration(this, data)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.getAbbreviation
|
||||
import org.jetbrains.kotlin.types.model.AnnotationMarker
|
||||
|
||||
+3
-1
@@ -31,6 +31,8 @@ import org.jetbrains.kotlin.resolve.scopes.TypeIntersectionScope;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -221,7 +223,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
@Nullable
|
||||
@Override
|
||||
protected KotlinType defaultSupertypeIfEmpty() {
|
||||
return ErrorUtils.createErrorType("Cyclic upper bounds");
|
||||
return ErrorUtils.createErrorType(ErrorTypeKind.CYCLIC_UPPER_BOUNDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parents
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeProjection
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
@@ -23,8 +23,9 @@ import org.jetbrains.kotlin.resolve.constants.KClassValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.declaresOrInheritsDefaultValue
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.ErrorUtils.UninferredParameterTypeConstructor
|
||||
import org.jetbrains.kotlin.types.TypeUtils.CANT_INFER_FUNCTION_PARAM_TYPE
|
||||
import org.jetbrains.kotlin.types.TypeUtils.CANNOT_INFER_FUNCTION_PARAM_TYPE
|
||||
import org.jetbrains.kotlin.types.error.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnresolvedType
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
|
||||
internal class DescriptorRendererImpl(
|
||||
@@ -153,13 +154,13 @@ internal class DescriptorRendererImpl(
|
||||
}
|
||||
|
||||
private fun StringBuilder.renderSimpleType(type: SimpleType) {
|
||||
if (type == CANT_INFER_FUNCTION_PARAM_TYPE || TypeUtils.isDontCarePlaceholder(type)) {
|
||||
if (type == CANNOT_INFER_FUNCTION_PARAM_TYPE || TypeUtils.isDontCarePlaceholder(type)) {
|
||||
append("???")
|
||||
return
|
||||
}
|
||||
if (ErrorUtils.isUninferredParameter(type)) {
|
||||
if (ErrorUtils.isUninferredTypeVariable(type)) {
|
||||
if (uninferredTypeParameterAsName) {
|
||||
append(renderError((type.constructor as UninferredParameterTypeConstructor).typeParameterDescriptor.name.toString()))
|
||||
append(renderError((type.constructor as ErrorTypeConstructor).getParam(0)))
|
||||
} else {
|
||||
append("???")
|
||||
}
|
||||
@@ -239,11 +240,11 @@ internal class DescriptorRendererImpl(
|
||||
|
||||
when {
|
||||
type.isError -> {
|
||||
if (type is UnresolvedType && presentableUnresolvedTypes) {
|
||||
append(type.presentableName)
|
||||
if (isUnresolvedType(type) && presentableUnresolvedTypes) {
|
||||
append(type.debugMessage)
|
||||
} else {
|
||||
if (type is ErrorType && !informativeErrorType) {
|
||||
append(type.presentableName)
|
||||
append(type.debugMessage)
|
||||
} else {
|
||||
append(type.constructor.toString()) // Debug name of an error type is more informative
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
+4
-2
@@ -18,10 +18,10 @@ package org.jetbrains.kotlin.resolve.calls.inference
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.Variance.IN_VARIANCE
|
||||
import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor
|
||||
import org.jetbrains.kotlin.types.model.CapturedTypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.CapturedTypeMarker
|
||||
import org.jetbrains.kotlin.types.TypeRefinement
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
interface CapturedTypeConstructor : CapturedTypeConstructorMarker, TypeConstructor {
|
||||
@@ -83,7 +84,8 @@ class CapturedType(
|
||||
|
||||
override val memberScope: MemberScope
|
||||
get() = ErrorUtils.createErrorScope(
|
||||
"No member resolution should be done on captured type, it used only during constraint system resolution", true
|
||||
ErrorScopeKind.CAPTURED_TYPE_SCOPE,
|
||||
throwExceptions = true
|
||||
)
|
||||
|
||||
override val subTypeRepresentative: KotlinType
|
||||
|
||||
@@ -19,9 +19,10 @@ package org.jetbrains.kotlin.resolve.constants
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
interface CompileTimeConstant<out T> {
|
||||
val isError: Boolean
|
||||
@@ -198,7 +199,7 @@ class IntegerValueTypeConstant(
|
||||
|
||||
val unknownIntegerType = KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
ErrorUtils.createErrorScope("Scope for number value type ($typeConstructor)", true)
|
||||
ErrorUtils.createErrorScope(ErrorScopeKind.INTEGER_LITERAL_TYPE_SCOPE, throwExceptions = true, typeConstructor.toString())
|
||||
)
|
||||
|
||||
fun getType(expectedType: KotlinType): KotlinType =
|
||||
|
||||
@@ -23,13 +23,14 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
||||
|
||||
abstract class ConstantValue<out T>(open val value: T) {
|
||||
@@ -120,7 +121,7 @@ class DoubleValue(value: Double) : ConstantValue<Double>(value) {
|
||||
class EnumValue(val enumClassId: ClassId, val enumEntryName: Name) : ConstantValue<Pair<ClassId, Name>>(enumClassId to enumEntryName) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType =
|
||||
module.findClassAcrossModuleDependencies(enumClassId)?.takeIf(DescriptorUtils::isEnumClass)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Containing class for error-class based enum entry $enumClassId.$enumEntryName")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.ERROR_ENUM_TYPE, enumClassId.toString(), enumEntryName.toString())
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitEnumValue(this, data)
|
||||
|
||||
@@ -139,7 +140,7 @@ abstract class ErrorValue : ConstantValue<Unit>(Unit) {
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitErrorValue(this, data)
|
||||
|
||||
class ErrorValueWithMessage(val message: String) : ErrorValue() {
|
||||
override fun getType(module: ModuleDescriptor) = ErrorUtils.createErrorType(message)
|
||||
override fun getType(module: ModuleDescriptor) = ErrorUtils.createErrorType(ErrorTypeKind.ERROR_CONSTANT_VALUE, message)
|
||||
|
||||
override fun toString() = message
|
||||
}
|
||||
@@ -188,7 +189,7 @@ class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(value) {
|
||||
is Value.NormalClass -> {
|
||||
val (classId, arrayDimensions) = value.value
|
||||
val descriptor = module.findClassAcrossModuleDependencies(classId)
|
||||
?: return ErrorUtils.createErrorType("Unresolved type: $classId (arrayDimensions=$arrayDimensions)")
|
||||
?: return ErrorUtils.createErrorType(ErrorTypeKind.UNRESOLVED_KCLASS_CONSTANT_VALUE, classId.toString(), arrayDimensions.toString())
|
||||
|
||||
// If this value refers to a class named test.Foo.Bar where both Foo and Bar have generic type parameters,
|
||||
// we're constructing a type `test.Foo<*>.Bar<*>` below
|
||||
@@ -266,7 +267,7 @@ class StringValue(value: String) : ConstantValue<String>(value) {
|
||||
class UByteValue(byteValue: Byte) : UnsignedValueConstant<Byte>(byteValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(StandardNames.FqNames.uByte)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type UByte not found")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_UNSIGNED_TYPE, "UByte")
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D): R = visitor.visitUByteValue(this, data)
|
||||
@@ -279,7 +280,7 @@ class UByteValue(byteValue: Byte) : UnsignedValueConstant<Byte>(byteValue) {
|
||||
class UShortValue(shortValue: Short) : UnsignedValueConstant<Short>(shortValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(StandardNames.FqNames.uShort)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type UShort not found")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_UNSIGNED_TYPE, "UShort")
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D): R = visitor.visitUShortValue(this, data)
|
||||
@@ -292,7 +293,7 @@ class UShortValue(shortValue: Short) : UnsignedValueConstant<Short>(shortValue)
|
||||
class UIntValue(intValue: Int) : UnsignedValueConstant<Int>(intValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(StandardNames.FqNames.uInt)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type UInt not found")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_UNSIGNED_TYPE, "UInt")
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitUIntValue(this, data)
|
||||
@@ -305,7 +306,7 @@ class UIntValue(intValue: Int) : UnsignedValueConstant<Int>(intValue) {
|
||||
class ULongValue(longValue: Long) : UnsignedValueConstant<Long>(longValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(StandardNames.FqNames.uLong)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type ULong not found")
|
||||
?: ErrorUtils.createErrorType(ErrorTypeKind.NOT_FOUND_UNSIGNED_TYPE, "ULong")
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D): R = visitor.visitULongValue(this, data)
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.checker.refineTypes
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
abstract class AbstractTypeConstructor(storageManager: StorageManager) : ClassifierBasedTypeConstructor() {
|
||||
override fun getSupertypes() = supertypes().supertypesWithoutCycles
|
||||
@@ -70,12 +71,12 @@ abstract class AbstractTypeConstructor(storageManager: StorageManager) : Classif
|
||||
// The first one is used for computation of neighbours in supertypes graph (see Companion.computeNeighbours)
|
||||
private class Supertypes(val allSupertypes: Collection<KotlinType>) {
|
||||
// initializer is only needed as a stub for case when 'getSupertypes' is called while 'supertypes' are being calculated
|
||||
var supertypesWithoutCycles: List<KotlinType> = listOf(ErrorUtils.ERROR_TYPE_FOR_LOOP_IN_SUPERTYPES)
|
||||
var supertypesWithoutCycles: List<KotlinType> = listOf(ErrorUtils.errorTypeForLoopInSupertypes)
|
||||
}
|
||||
|
||||
private val supertypes = storageManager.createLazyValueWithPostCompute(
|
||||
{ Supertypes(computeSupertypes()) },
|
||||
{ Supertypes(listOf(ErrorUtils.ERROR_TYPE_FOR_LOOP_IN_SUPERTYPES)) },
|
||||
{ Supertypes(listOf(ErrorUtils.errorTypeForLoopInSupertypes)) },
|
||||
{ supertypes ->
|
||||
// It's important that loops disconnection begins in post-compute phase, because it guarantees that
|
||||
// when we start calculation supertypes of supertypes (for computing neighbours), they start their disconnection loop process
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
|
||||
abstract class ClassifierBasedTypeConstructor : TypeConstructor {
|
||||
private var hashCode = 0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user