[FE 1.0] Migrate most of warning/error pairs to DiagnosticFactoryForDeprecation
This commit is contained in:
+1
-6
@@ -554,12 +554,7 @@ class ControlFlowInformationProviderImpl private constructor(
|
||||
}
|
||||
|
||||
private fun reportValReassigned(expression: KtExpression, variableDescriptor: VariableDescriptor, ctxt: VariableInitContext) {
|
||||
val diagnosticFactory = if (languageVersionSettings.supportsFeature(LanguageFeature.RestrictionOfValReassignmentViaBackingField))
|
||||
VAL_REASSIGNMENT_VIA_BACKING_FIELD_ERROR
|
||||
else
|
||||
VAL_REASSIGNMENT_VIA_BACKING_FIELD
|
||||
|
||||
report(diagnosticFactory.on(expression, variableDescriptor), ctxt)
|
||||
report(VAL_REASSIGNMENT_VIA_BACKING_FIELD.on(languageVersionSettings, expression, variableDescriptor), ctxt)
|
||||
}
|
||||
|
||||
private fun checkAssignmentBeforeDeclaration(ctxt: VariableInitContext, expression: KtExpression) =
|
||||
|
||||
@@ -246,8 +246,7 @@ public interface Errors {
|
||||
// Annotations
|
||||
|
||||
DiagnosticFactory0<KtSuperTypeList> SUPERTYPES_FOR_ANNOTATION_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> ANNOTATION_ON_SUPERCLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> ANNOTATION_ON_SUPERCLASS_WARNING = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactoryForDeprecation0<KtAnnotationEntry> ANNOTATION_ON_SUPERCLASS = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitUseSiteTargetAnnotationsOnSuperTypes);
|
||||
DiagnosticFactory0<KtParameter> MISSING_VAL_ON_ANNOTATION_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> VAR_ANNOTATION_PARAMETER = DiagnosticFactory0.create(ERROR, VAL_OR_VAR_NODE);
|
||||
DiagnosticFactory0<KtCallExpression> ANNOTATION_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
|
||||
@@ -265,11 +264,9 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtAnnotationEntry> ANNOTATION_USED_AS_ANNOTATION_ARGUMENT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_IS_NON_CONST = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<PsiElement> RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION_WARNING = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactoryForDeprecation0<PsiElement> RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION = DiagnosticFactoryForDeprecation0.create(LanguageFeature.RestrictRetentionForExpressionAnnotations);
|
||||
|
||||
DiagnosticFactory0<KtClassOrObject> LOCAL_ANNOTATION_CLASS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtClassOrObject> LOCAL_ANNOTATION_CLASS_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<KtClassOrObject> LOCAL_ANNOTATION_CLASS = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitLocalAnnotations);
|
||||
|
||||
DiagnosticFactory1<PsiElement, FqName> ILLEGAL_KOTLIN_VERSION_STRING_VALUE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, String> NEWER_VERSION_IN_SINCE_KOTLIN = DiagnosticFactory1.create(WARNING);
|
||||
@@ -448,8 +445,7 @@ public interface Errors {
|
||||
// Companion objects
|
||||
|
||||
DiagnosticFactory0<KtObjectDeclaration> MANY_COMPANION_OBJECTS = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
|
||||
DiagnosticFactory0<KtExpression> SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR_WARNING = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtExpression> SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<KtExpression> SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitSelfCallsInNestedObjects);
|
||||
|
||||
// Objects
|
||||
|
||||
@@ -510,10 +506,9 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory2<PsiElement, CallableMemberDescriptor, DeclarationDescriptor> DATA_CLASS_OVERRIDE_CONFLICT =
|
||||
DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, CallableMemberDescriptor, DeclarationDescriptor> DATA_CLASS_OVERRIDE_DEFAULT_VALUES_WARNING =
|
||||
DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, CallableMemberDescriptor, DeclarationDescriptor> DATA_CLASS_OVERRIDE_DEFAULT_VALUES_ERROR =
|
||||
DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation2<PsiElement, CallableMemberDescriptor, DeclarationDescriptor> DATA_CLASS_OVERRIDE_DEFAULT_VALUES =
|
||||
DiagnosticFactoryForDeprecation2.create(LanguageFeature.ProhibitDataClassesOverridingCopy);
|
||||
// DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtDeclaration, CallableMemberDescriptor> CANNOT_INFER_VISIBILITY =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
@@ -562,10 +557,8 @@ public interface Errors {
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED_WARNING =
|
||||
DiagnosticFactory2.create(WARNING, DECLARATION_NAME);
|
||||
DiagnosticFactory2<KtClassOrObject, ClassDescriptor, Collection<CallableMemberDescriptor>> INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory2<KtClassOrObject, ClassDescriptor, Collection<CallableMemberDescriptor>> INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING =
|
||||
DiagnosticFactory2.create(WARNING, DECLARATION_NAME);
|
||||
DiagnosticFactoryForDeprecation2<KtClassOrObject, ClassDescriptor, Collection<CallableMemberDescriptor>> INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER =
|
||||
DiagnosticFactoryForDeprecation2.create(LanguageFeature.ProhibitInvisibleAbstractMethodsInSuperclasses, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory1<KtDeclaration, Collection<KotlinType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||
@@ -644,8 +637,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtParameter> VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtNamedFunction> NO_TAIL_CALLS_FOUND = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtNamedFunction> TAILREC_ON_VIRTUAL_MEMBER = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtNamedFunction> TAILREC_ON_VIRTUAL_MEMBER_ERROR = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactoryForDeprecation0<KtNamedFunction> TAILREC_ON_VIRTUAL_MEMBER = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitTailrecOnVirtualMember, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<KtParameter>
|
||||
ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
||||
@@ -769,11 +761,9 @@ public interface Errors {
|
||||
DiagnosticFactory1<KtExpression, KotlinType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KotlinType> ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation1<KtExpression, KotlinType> ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION = DiagnosticFactoryForDeprecation1.create(LanguageFeature.ProhibitAssigningSingleElementsToVarargsInNamedForm);
|
||||
DiagnosticFactory0<KtExpression> REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_FUNCTION = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtExpression> ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtExpression> ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<KtExpression> ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitAssigningSingleElementsToVarargsInNamedForm);
|
||||
DiagnosticFactory0<KtExpression> REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Call resolution
|
||||
@@ -797,8 +787,7 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends CallableDescriptor>> CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED_ARRAY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED_ARRAY_WARNING = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactoryForDeprecation1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED_ARRAY = DiagnosticFactoryForDeprecation1.create(LanguageFeature.ProhibitNonReifiedArraysAsReifiedTypeArguments);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> REIFIED_TYPE_UNSAFE_SUBSTITUTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<KtElement> CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION = DiagnosticFactory0.create(WARNING);
|
||||
@@ -985,8 +974,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtLambdaExpression> UNUSED_LAMBDA_EXPRESSION = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> VAL_REASSIGNMENT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> VAL_REASSIGNMENT_VIA_BACKING_FIELD = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> VAL_REASSIGNMENT_VIA_BACKING_FIELD_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation1<KtExpression, DeclarationDescriptor> VAL_REASSIGNMENT_VIA_BACKING_FIELD = DiagnosticFactoryForDeprecation1.create(LanguageFeature.RestrictionOfValReassignmentViaBackingField);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> CAPTURED_VAL_INITIALIZATION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> CAPTURED_MEMBER_VAL_INITIALIZATION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> SETTER_PROJECTED_OUT = DiagnosticFactory1.create(ERROR);
|
||||
@@ -1165,9 +1153,8 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> NON_LOCAL_RETURN_IN_DISABLED_INLINE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDeclaration> INLINE_PROPERTY_WITH_BACKING_FIELD = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtAnnotationEntry> NON_INTERNAL_PUBLISHED_API = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> PROTECTED_CALL_FROM_PUBLIC_INLINE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactoryForDeprecation1<PsiElement, CallableDescriptor> PROTECTED_CALL_FROM_PUBLIC_INLINE = DiagnosticFactoryForDeprecation1.create(LanguageFeature.ProhibitProtectedCallFromInline);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> SUPER_CALL_FROM_PUBLIC_INLINE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory2<KtElement, KtExpression, DeclarationDescriptor> INVALID_DEFAULT_FUNCTIONAL_PARAMETER_FOR_INLINE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtExpression, DeclarationDescriptor> NOT_SUPPORTED_INLINE_PARAMETER_IN_INLINE_PARAMETER_DEFAULT_VALUE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
+7
-20
@@ -333,8 +333,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(VIRTUAL_MEMBER_HIDDEN, "''{0}'' hides member of supertype ''{2}'' and needs ''override'' modifier", NAME, NAME, NAME);
|
||||
|
||||
MAP.put(DATA_CLASS_OVERRIDE_CONFLICT, "Function ''{0}'' generated for the data class conflicts with member of supertype ''{1}''", NAME, NAME);
|
||||
MAP.put(DATA_CLASS_OVERRIDE_DEFAULT_VALUES_WARNING, "Function ''{0}'' generated for the data class has default values for parameters, and conflicts with member of supertype ''{1}''", NAME, NAME);
|
||||
MAP.put(DATA_CLASS_OVERRIDE_DEFAULT_VALUES_ERROR, "Function ''{0}'' generated for the data class has default values for parameters, and conflicts with member of supertype ''{1}''", NAME, NAME);
|
||||
MAP.put(DATA_CLASS_OVERRIDE_DEFAULT_VALUES, "Function ''{0}'' generated for the data class has default values for parameters, and conflicts with member of supertype ''{1}''", NAME, NAME);
|
||||
|
||||
MAP.put(CANNOT_OVERRIDE_INVISIBLE_MEMBER, "''{0}'' has no access to ''{1}'', so it cannot override it", FQ_NAMES_IN_TYPES,
|
||||
FQ_NAMES_IN_TYPES);
|
||||
@@ -358,8 +357,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(UNUSED_LAMBDA_EXPRESSION, "The lambda expression is unused. If you mean a block, you can use 'run { ... }'");
|
||||
|
||||
MAP.put(VAL_REASSIGNMENT, "Val cannot be reassigned", NAME);
|
||||
MAP.put(VAL_REASSIGNMENT_VIA_BACKING_FIELD, "Reassignment of read-only property via backing field is deprecated", NAME);
|
||||
MAP.put(VAL_REASSIGNMENT_VIA_BACKING_FIELD_ERROR, "Reassignment of read-only property via backing field", NAME);
|
||||
MAP.put(VAL_REASSIGNMENT_VIA_BACKING_FIELD, "Reassignment of read-only property via backing field", NAME);
|
||||
MAP.put(CAPTURED_VAL_INITIALIZATION, "Captured values initialization is forbidden due to possible reassignment", NAME);
|
||||
MAP.put(CAPTURED_MEMBER_VAL_INITIALIZATION, "Captured member values initialization is forbidden due to possible reassignment", NAME);
|
||||
MAP.put(SETTER_PROJECTED_OUT, "Setter for ''{0}'' is removed by type projection", NAME);
|
||||
@@ -377,7 +375,6 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class");
|
||||
|
||||
MAP.put(SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR_WARNING, "Self references to members of containing class are prohibited in constructor of nested object");
|
||||
MAP.put(SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR, "Self references to members of containing class are prohibited in constructor of nested object");
|
||||
|
||||
MAP.put(DEPRECATION, "''{0}'' is deprecated. {1}", DEPRECATION_RENDERER, STRING);
|
||||
@@ -680,8 +677,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(ILLEGAL_SELECTOR, "The expression cannot be a selector (occur after a dot)");
|
||||
|
||||
MAP.put(NO_TAIL_CALLS_FOUND, "A function is marked as tail-recursive but no tail calls are found");
|
||||
MAP.put(TAILREC_ON_VIRTUAL_MEMBER, "Tailrec on open members is deprecated");
|
||||
MAP.put(TAILREC_ON_VIRTUAL_MEMBER_ERROR, "Tailrec is not allowed on open members");
|
||||
MAP.put(TAILREC_ON_VIRTUAL_MEMBER, "Tailrec is not allowed on open members");
|
||||
|
||||
MAP.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter");
|
||||
MAP.put(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP, "'break' and 'continue' are only allowed inside a loop");
|
||||
@@ -877,7 +873,6 @@ public class DefaultErrorMessages {
|
||||
MAP.put(MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED_WARNING, "Deprecated: {0} must override {1} because it inherits multiple interface methods of it",
|
||||
RENDER_CLASS_OR_OBJECT, FQ_NAMES_IN_TYPES);
|
||||
MAP.put(INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER, "{0} inherits invisible abstract members: {1}", NAME, commaSeparated(FQ_NAMES_IN_TYPES));
|
||||
MAP.put(INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING, "{0} inherits invisible abstract members: {1}", NAME, commaSeparated(FQ_NAMES_IN_TYPES));
|
||||
|
||||
MAP.put(CONFLICTING_OVERLOADS, "Conflicting overloads: {0}", commaSeparated(FQ_NAMES_IN_TYPES));
|
||||
|
||||
@@ -910,11 +905,9 @@ public class DefaultErrorMessages {
|
||||
MAP.put(NO_VALUE_FOR_PARAMETER, "No value passed for parameter ''{0}''", NAME);
|
||||
MAP.put(MISSING_RECEIVER, "A receiver of type {0} is required", RENDER_TYPE);
|
||||
MAP.put(NO_RECEIVER_ALLOWED, "No receiver can be passed to this function or property");
|
||||
MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION, "Assigning single elements to varargs in named form is deprecated", TO_STRING);
|
||||
MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION_ERROR, "Assigning single elements to varargs in named form is forbidden", TO_STRING);
|
||||
MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION, "Assigning single elements to varargs in named form is forbidden", TO_STRING);
|
||||
MAP.put(REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_FUNCTION, "Redundant spread (*) operator");
|
||||
MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION, "Assigning single elements to varargs in named form is deprecated");
|
||||
MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR, "Assigning single elements to varargs in named form is forbidden");
|
||||
MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION, "Assigning single elements to varargs in named form is forbidden");
|
||||
MAP.put(REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION, "Redundant spread (*) operator");
|
||||
|
||||
MAP.put(CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS, "Cannot create an instance of an abstract class");
|
||||
@@ -948,7 +941,6 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(TYPE_PARAMETER_AS_REIFIED, "Cannot use ''{0}'' as reified type parameter. Use a class instead.", NAME);
|
||||
MAP.put(TYPE_PARAMETER_AS_REIFIED_ARRAY, "Cannot use ''{0}'' as reified type parameter, since the array type parameter is not reified.", NAME);
|
||||
MAP.put(TYPE_PARAMETER_AS_REIFIED_ARRAY_WARNING, "Cannot use ''{0}'' as reified type parameter, since the array type parameter is not reified.", NAME);
|
||||
MAP.put(REIFIED_TYPE_PARAMETER_NO_INLINE, "Only type parameters of inline functions can be reified");
|
||||
MAP.put(REIFIED_TYPE_FORBIDDEN_SUBSTITUTION, "Cannot use ''{0}'' as reified type parameter", RENDER_TYPE);
|
||||
MAP.put(REIFIED_TYPE_UNSAFE_SUBSTITUTION, "It may be not safe to use ''{0}'' as an argument for a reified type parameter. Use a non-generic type or * if possible", RENDER_TYPE);
|
||||
@@ -983,14 +975,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION,
|
||||
"Expression annotations with retention other than SOURCE are prohibited");
|
||||
MAP.put(RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION_WARNING,
|
||||
"Expression annotations with retention other than SOURCE are deprecated");
|
||||
|
||||
MAP.put(LOCAL_ANNOTATION_CLASS, "Local annotation classes are deprecated and will be unsupported in a future release");
|
||||
MAP.put(LOCAL_ANNOTATION_CLASS_ERROR, "Annotation class cannot be local");
|
||||
MAP.put(LOCAL_ANNOTATION_CLASS, "Annotation class cannot be local");
|
||||
|
||||
MAP.put(ANNOTATION_ON_SUPERCLASS, "Annotations on superclass are meaningless");
|
||||
MAP.put(ANNOTATION_ON_SUPERCLASS_WARNING, "Annotations on superclass are meaningless and deprecated");
|
||||
|
||||
MAP.put(CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT, "Const 'val' are only allowed on top level or in objects");
|
||||
MAP.put(CONST_VAL_WITH_DELEGATE, "Const 'val' should not have a delegate");
|
||||
@@ -1055,9 +1043,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(RECURSION_IN_INLINE, "Inline function ''{1}'' cannot be recursive", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(INLINE_PROPERTY_WITH_BACKING_FIELD, "Inline property cannot have backing field");
|
||||
MAP.put(NON_INTERNAL_PUBLISHED_API, "@PublishedApi annotation is only applicable for internal declaration");
|
||||
MAP.put(PROTECTED_CALL_FROM_PUBLIC_INLINE, "Protected function call from public-API inline function is deprecated", NAME);
|
||||
MAP.put(PROTECTED_CALL_FROM_PUBLIC_INLINE, "Protected function call from public-API inline function is prohibited", NAME);
|
||||
MAP.put(PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE, "Protected constructor call from public-API inline function is deprecated", NAME);
|
||||
MAP.put(PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR, "Protected function call from public-API inline function is prohibited", NAME);
|
||||
MAP.put(SUPER_CALL_FROM_PUBLIC_INLINE, "Accessing super members from public-API inline function is deprecated", NAME);
|
||||
MAP.put(INVALID_DEFAULT_FUNCTIONAL_PARAMETER_FOR_INLINE, "Invalid default value for inline parameter: ''{0}''. Only lambdas, anonymous functions, and callable references are supported", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(NOT_SUPPORTED_INLINE_PARAMETER_IN_INLINE_PARAMETER_DEFAULT_VALUE, "Usage of inline parameter ''{0}'' in default value for another inline parameter is not supported", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
|
||||
|
||||
@@ -170,13 +170,7 @@ class AnnotationChecker(
|
||||
}
|
||||
val actualTargets = getActualTargetList(reference, null, trace.bindingContext)
|
||||
if (entry.useSiteTarget != null && isSuperType) {
|
||||
val reportError = languageVersionSettings.supportsFeature(ProhibitUseSiteTargetAnnotationsOnSuperTypes)
|
||||
val diagnostic = if (reportError) {
|
||||
Errors.ANNOTATION_ON_SUPERCLASS.on(entry)
|
||||
} else {
|
||||
Errors.ANNOTATION_ON_SUPERCLASS_WARNING.on(entry)
|
||||
}
|
||||
trace.report(diagnostic)
|
||||
trace.report(Errors.ANNOTATION_ON_SUPERCLASS.on(languageVersionSettings, entry))
|
||||
} else if (shouldRunCheck && (languageVersionSettings.supportsFeature(ProperCheckAnnotationsTargetInTypeUsePositions) || checkWithoutLanguageFeature)) {
|
||||
checkAnnotationEntry(entry, actualTargets, trace)
|
||||
}
|
||||
|
||||
@@ -347,11 +347,7 @@ class DeclarationsChecker(
|
||||
|
||||
private fun checkLocalAnnotation(classDescriptor: ClassDescriptor, classOrObject: KtClassOrObject) {
|
||||
if (classDescriptor.kind == ClassKind.ANNOTATION_CLASS && DescriptorUtils.isLocal(classDescriptor)) {
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitLocalAnnotations)) {
|
||||
trace.report(LOCAL_ANNOTATION_CLASS_ERROR.on(classOrObject))
|
||||
} else {
|
||||
trace.report(LOCAL_ANNOTATION_CLASS.on(classOrObject))
|
||||
}
|
||||
trace.report(LOCAL_ANNOTATION_CLASS.on(languageVersionSettings, classOrObject))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,11 +270,7 @@ class OverrideResolver(
|
||||
}
|
||||
|
||||
if (abstractInvisibleSuper.isNotEmpty() && !canHaveAbstractMembers) {
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitInvisibleAbstractMethodsInSuperclasses)) {
|
||||
trace.report(INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER.on(klass, classDescriptor, abstractInvisibleSuper))
|
||||
} else {
|
||||
trace.report(INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING.on(klass, classDescriptor, abstractInvisibleSuper))
|
||||
}
|
||||
trace.report(INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER.on(languageVersionSettings, klass, classDescriptor, abstractInvisibleSuper))
|
||||
}
|
||||
|
||||
conflictingInterfaceMembers.removeAll(conflictingReturnTypes)
|
||||
@@ -410,11 +406,7 @@ class OverrideResolver(
|
||||
if (overridden != null) {
|
||||
val baseClassifier = overridden.containingDeclaration
|
||||
val dataModifier = findDataModifierForDataClass(copyFunction.containingDeclaration)
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitDataClassesOverridingCopy)) {
|
||||
trace.report(DATA_CLASS_OVERRIDE_DEFAULT_VALUES_ERROR.on(dataModifier, copyFunction, baseClassifier))
|
||||
} else {
|
||||
trace.report(DATA_CLASS_OVERRIDE_DEFAULT_VALUES_WARNING.on(dataModifier, copyFunction, baseClassifier))
|
||||
}
|
||||
trace.report(DATA_CLASS_OVERRIDE_DEFAULT_VALUES.on(languageVersionSettings, dataModifier, copyFunction, baseClassifier))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-38
@@ -8,10 +8,8 @@ package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature.*
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION_ERROR
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.ValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isArrayOrArrayLiteral
|
||||
@@ -21,18 +19,6 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isParameterOfAnnotation
|
||||
|
||||
class AssigningNamedArgumentToVarargChecker : CallChecker {
|
||||
companion object {
|
||||
private val migrationDiagnosticsForFunction = MigrationDiagnostics(
|
||||
ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION,
|
||||
ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION_ERROR
|
||||
)
|
||||
|
||||
private val migrationDiagnosticsForAnnotation = MigrationDiagnostics(
|
||||
Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION,
|
||||
Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR
|
||||
)
|
||||
}
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
for ((parameterDescriptor, resolvedArgument) in resolvedCall.valueArguments) {
|
||||
for (argument in resolvedArgument.arguments) {
|
||||
@@ -71,9 +57,9 @@ class AssigningNamedArgumentToVarargChecker : CallChecker {
|
||||
context.trace.report(Errors.REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION.on(argumentExpression))
|
||||
}
|
||||
} else {
|
||||
reportMigrationDiagnostic(migrationDiagnosticsForAnnotation, context) { diagnostic ->
|
||||
context.trace.report(diagnostic.on(argumentExpression))
|
||||
}
|
||||
context.trace.report(
|
||||
Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION.on(context.languageVersionSettings, argumentExpression)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,30 +78,16 @@ class AssigningNamedArgumentToVarargChecker : CallChecker {
|
||||
}
|
||||
} else {
|
||||
if (!argument.hasSpread()) {
|
||||
reportMigrationDiagnostic(migrationDiagnosticsForFunction, context) { diagnostic ->
|
||||
context.trace.report(diagnostic.on(argumentExpression, parameterDescriptor.type))
|
||||
}
|
||||
context.trace.report(
|
||||
ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION.on(
|
||||
context.languageVersionSettings,
|
||||
argumentExpression,
|
||||
parameterDescriptor.type
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ValueArgument.hasSpread() = getSpreadElement() != null
|
||||
|
||||
private inline fun <T : DiagnosticFactory<*>> reportMigrationDiagnostic(
|
||||
migrationDiagnostics: MigrationDiagnostics<T>,
|
||||
context: ResolutionContext<*>,
|
||||
report: (T) -> Unit
|
||||
) {
|
||||
val (warning, error) = migrationDiagnostics
|
||||
if (context.languageVersionSettings.supportsFeature(ProhibitAssigningSingleElementsToVarargsInNamedForm)) {
|
||||
report(error)
|
||||
} else {
|
||||
report(warning)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private data class MigrationDiagnostics<T : DiagnosticFactory<*>>(val warning: T, val error: T)
|
||||
|
||||
private val ResolutionContext<*>.isAssigningArrayEnabled: Boolean
|
||||
get() = languageVersionSettings.supportsFeature(AllowAssigningArrayElementsToVarargsInNamedFormForFunctions)
|
||||
@@ -60,14 +60,11 @@ internal class InlineChecker(private val descriptor: FunctionDescriptor) : CallC
|
||||
|
||||
private var supportDefaultValueInline by Delegates.notNull<Boolean>()
|
||||
|
||||
private var prohibitProtectedCallFromInline by Delegates.notNull<Boolean>()
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val call = resolvedCall.call
|
||||
val expression = call.calleeExpression ?: return
|
||||
|
||||
supportDefaultValueInline = context.languageVersionSettings.supportsFeature(LanguageFeature.InlineDefaultFunctionalParameters)
|
||||
prohibitProtectedCallFromInline = context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitProtectedCallFromInline)
|
||||
|
||||
//checking that only invoke or inlinable extension called on function parameter
|
||||
val targetDescriptor = resolvedCall.resultingDescriptor
|
||||
@@ -282,11 +279,10 @@ internal class InlineChecker(private val descriptor: FunctionDescriptor) : CallC
|
||||
isConstructorCall -> {
|
||||
context.trace.report(PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE.on(expression, calledDescriptor))
|
||||
}
|
||||
prohibitProtectedCallFromInline -> {
|
||||
context.trace.report(PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR.on(expression, calledDescriptor))
|
||||
}
|
||||
else -> {
|
||||
context.trace.report(PROTECTED_CALL_FROM_PUBLIC_INLINE.on(expression, calledDescriptor))
|
||||
context.trace.report(
|
||||
PROTECTED_CALL_FROM_PUBLIC_INLINE.on(context.languageVersionSettings, expression, calledDescriptor)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -67,11 +67,7 @@ public class ReifiedTypeParameterSubstitutionChecker implements CallChecker {
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> diagnosticFactory;
|
||||
|
||||
if (isArrayArgumentCheck) {
|
||||
if (context.getLanguageVersionSettings().supportsFeature(LanguageFeature.ProhibitNonReifiedArraysAsReifiedTypeArguments)) {
|
||||
diagnosticFactory = Errors.TYPE_PARAMETER_AS_REIFIED_ARRAY;
|
||||
} else {
|
||||
diagnosticFactory = Errors.TYPE_PARAMETER_AS_REIFIED_ARRAY_WARNING;
|
||||
}
|
||||
diagnosticFactory = Errors.TYPE_PARAMETER_AS_REIFIED_ARRAY.chooseFactory(context.getLanguageVersionSettings());
|
||||
} else {
|
||||
diagnosticFactory = Errors.TYPE_PARAMETER_AS_REIFIED;
|
||||
}
|
||||
|
||||
+4
-9
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
@@ -32,8 +33,7 @@ object SelfCallInNestedObjectConstructorChecker : CallChecker {
|
||||
if (constructedObject.kind != ClassKind.OBJECT) return
|
||||
val containingClass = constructedObject.containingDeclaration as? ClassDescriptor ?: return
|
||||
if (candidateDescriptor.constructedClass == containingClass) {
|
||||
val reportError = context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitSelfCallsInNestedObjects)
|
||||
val visitor = Visitor(containingClass, context.trace, reportError)
|
||||
val visitor = Visitor(containingClass, context.trace, context.languageVersionSettings)
|
||||
resolvedCall.call.valueArgumentList?.accept(visitor)
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ object SelfCallInNestedObjectConstructorChecker : CallChecker {
|
||||
private class Visitor(
|
||||
val containingClass: ClassDescriptor,
|
||||
val trace: BindingTrace,
|
||||
val reportError: Boolean
|
||||
val languageVersionSettings: LanguageVersionSettings
|
||||
) : KtVisitorVoid() {
|
||||
override fun visitKtElement(element: KtElement) {
|
||||
element.acceptChildren(this, null)
|
||||
@@ -65,12 +65,7 @@ object SelfCallInNestedObjectConstructorChecker : CallChecker {
|
||||
val receiverType = receiver?.type ?: return
|
||||
val receiverClass = receiverType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||
if (DescriptorUtils.isSubclass(receiverClass, containingClass)) {
|
||||
val factory = if (reportError) {
|
||||
Errors.SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR
|
||||
} else {
|
||||
Errors.SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR_WARNING
|
||||
}
|
||||
trace.report(factory.on(argument))
|
||||
trace.report(Errors.SELF_CALL_IN_NESTED_OBJECT_CONSTRUCTOR.on(languageVersionSettings, argument))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -34,12 +34,12 @@ class AnnotationClassTargetAndRetentionChecker : DeclarationChecker {
|
||||
val retentionAnnotation = descriptor.annotations.findAnnotation(StandardNames.FqNames.retention)
|
||||
val targetAnnotation = descriptor.annotations.findAnnotation(StandardNames.FqNames.target)
|
||||
|
||||
val diagnostics =
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.RestrictRetentionForExpressionAnnotations))
|
||||
Errors.RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION
|
||||
else
|
||||
Errors.RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION_WARNING
|
||||
context.trace.report(diagnostics.on(retentionAnnotation?.psi ?: targetAnnotation?.psi ?: declaration))
|
||||
context.trace.report(
|
||||
Errors.RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION.on(
|
||||
context.languageVersionSettings,
|
||||
retentionAnnotation?.psi ?: targetAnnotation?.psi ?: declaration
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-7
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -19,10 +18,6 @@ object TailrecFunctionChecker : DeclarationChecker {
|
||||
|
||||
if (descriptor.isEffectivelyFinal(false)) return
|
||||
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitTailrecOnVirtualMember)) {
|
||||
context.trace.report(Errors.TAILREC_ON_VIRTUAL_MEMBER.on(declaration))
|
||||
} else {
|
||||
context.trace.report(Errors.TAILREC_ON_VIRTUAL_MEMBER_ERROR.on(declaration))
|
||||
}
|
||||
context.trace.report(Errors.TAILREC_ON_VIRTUAL_MEMBER.on(context.languageVersionSettings, declaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user