[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
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user