[FE 1.0] Migrate most of warning/error pairs to DiagnosticFactoryForDeprecation
This commit is contained in:
+1
-7
@@ -37,13 +37,7 @@ object InconsistentOperatorFromJavaCallChecker : CallChecker {
|
||||
val containingClass = callableDescriptor.containingDeclaration as? ClassDescriptor ?: continue
|
||||
if (containingClass.fqNameOrNull() != CONCURRENT_HASH_MAP_FQ_NAME) continue
|
||||
|
||||
val diagnosticFactory =
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitConcurrentHashMapContains))
|
||||
ErrorsJvm.CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR
|
||||
else
|
||||
ErrorsJvm.CONCURRENT_HASH_MAP_CONTAINS_OPERATOR
|
||||
|
||||
context.trace.report(diagnosticFactory.on(reportOn))
|
||||
context.trace.report(ErrorsJvm.CONCURRENT_HASH_MAP_CONTAINS_OPERATOR.on(context.languageVersionSettings, reportOn))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
+2
-7
@@ -51,8 +51,7 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
||||
isStaticDeclaration(descriptor) &&
|
||||
isInterface(descriptor.containingDeclaration) &&
|
||||
descriptor is JavaCallableMemberDescriptor) {
|
||||
val diagnostic = if (isDefaultCallsProhibited(context)) INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET
|
||||
context.trace.report(diagnostic.on(reportOn))
|
||||
context.trace.report(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET.on(context.languageVersionSettings, reportOn))
|
||||
}
|
||||
|
||||
val superCallExpression = getSuperCallExpression(resolvedCall.call) ?: return
|
||||
@@ -76,9 +75,7 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
||||
}
|
||||
|
||||
if (!supportDefaults) {
|
||||
val diagnostic =
|
||||
if (isDefaultCallsProhibited(context)) DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET
|
||||
context.trace.report(diagnostic.on(reportOn))
|
||||
context.trace.report(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET.on(context.languageVersionSettings, reportOn))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,8 +101,6 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker
|
||||
return null
|
||||
}
|
||||
|
||||
private fun isDefaultCallsProhibited(context: CallCheckerContext) =
|
||||
context.languageVersionSettings.supportsFeature(LanguageFeature.DefaultMethodsCallFromJava6TargetError)
|
||||
|
||||
private fun getSuperCallLabelTarget(
|
||||
bindingContext: BindingContext,
|
||||
|
||||
+1
-6
@@ -26,12 +26,7 @@ object PolymorphicSignatureCallChecker : CallChecker {
|
||||
if (valueArgument !is VarargValueArgument) continue
|
||||
for (argument in valueArgument.arguments) {
|
||||
val spread = argument.getSpreadElement() ?: continue
|
||||
val diagnostic =
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitSpreadOnSignaturePolymorphicCall))
|
||||
ErrorsJvm.SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL_ERROR
|
||||
else
|
||||
ErrorsJvm.SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL
|
||||
context.trace.report(diagnostic.on(spread))
|
||||
context.trace.report(ErrorsJvm.SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL.on(context.languageVersionSettings, spread))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -235,13 +235,7 @@ class OverloadsAnnotationChecker : DeclarationChecker {
|
||||
diagnosticHolder.report(ErrorsJvm.OVERLOADS_LOCAL.on(annotationEntry))
|
||||
|
||||
descriptor.isAnnotationConstructor() -> {
|
||||
val diagnostic =
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitJvmOverloadsOnConstructorsOfAnnotationClasses))
|
||||
ErrorsJvm.OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR
|
||||
else
|
||||
ErrorsJvm.OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR_WARNING
|
||||
|
||||
diagnosticHolder.report(diagnostic.on(annotationEntry))
|
||||
diagnosticHolder.report(ErrorsJvm.OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR.on(context.languageVersionSettings, annotationEntry))
|
||||
}
|
||||
|
||||
!descriptor.visibility.isPublicAPI && descriptor.visibility != DescriptorVisibilities.INTERNAL ->
|
||||
|
||||
+2
-7
@@ -51,7 +51,6 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
MAP.put(OVERLOADS_INTERFACE, "'@JvmOverloads' annotation cannot be used on interface methods");
|
||||
MAP.put(OVERLOADS_PRIVATE, "'@JvmOverloads' annotation has no effect on private declarations");
|
||||
MAP.put(OVERLOADS_LOCAL, "'@JvmOverloads' annotation cannot be used on local declarations");
|
||||
MAP.put(OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR_WARNING, "'@JvmOverloads' annotation on constructors of annotation classes is deprecated");
|
||||
MAP.put(OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR, "'@JvmOverloads' annotation cannot be used on constructors of annotation classes");
|
||||
MAP.put(OVERLOADS_ANNOTATION_HIDDEN_CONSTRUCTOR, "'@JvmOverloads' annotation cannot be used on constructors hidden by inline class rules");
|
||||
MAP.put(OVERLOADS_ANNOTATION_MANGLED_FUNCTION, "'@JvmOverloads' annotation cannot be used on functions mangled by inline class rules");
|
||||
@@ -147,10 +146,8 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
"Please make explicit overrides (abstract or concrete) for the following non-abstract members of ''{1}'': {2}",
|
||||
NAME, NAME, STRING);
|
||||
|
||||
MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET, "Super calls to Java default methods are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR, "Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET, "Calls to static methods in Java interfaces are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR, "Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET, "Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET, "Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'");
|
||||
|
||||
MAP.put(INLINE_FROM_HIGHER_PLATFORM, "Cannot inline bytecode built with {0} into bytecode that is being built with {1}. Please specify proper ''-jvm-target'' option", STRING, STRING);
|
||||
MAP.put(INLINE_FROM_HIGHER_PLATFORM_WARNING, "Cannot inline bytecode built with {0} into bytecode that is being built with {1}. Please specify proper ''-jvm-target'' option", STRING, STRING);
|
||||
@@ -195,12 +192,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
"Use explicit form of the call to 'containsKey'/'containsValue'/'contains' or cast the value to kotlin.collections.Map instead. " +
|
||||
"See https://youtrack.jetbrains.com/issue/KT-18053 for more details";
|
||||
MAP.put(CONCURRENT_HASH_MAP_CONTAINS_OPERATOR, MESSAGE_FOR_CONCURRENT_HASH_MAP_CONTAINS);
|
||||
MAP.put(CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR, MESSAGE_FOR_CONCURRENT_HASH_MAP_CONTAINS);
|
||||
MAP.put(TAILREC_WITH_DEFAULTS, "Computation order of non-constant default arguments in tail-recursive functions will change in 1.4. See KT-31540 for more details");
|
||||
|
||||
String spreadOnPolymorphicSignature = "Spread operator is prohibited for arguments to signature-polymorphic calls";
|
||||
MAP.put(SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL, spreadOnPolymorphicSignature);
|
||||
MAP.put(SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL_ERROR, spreadOnPolymorphicSignature);
|
||||
|
||||
MAP.put(FUNCTION_DELEGATE_MEMBER_NAME_CLASH,
|
||||
"Functional interface member cannot have this name on JVM because it clashes with an internal member getFunctionDelegate");
|
||||
|
||||
+6
-10
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.jvm.diagnostics;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
@@ -58,8 +59,7 @@ public interface ErrorsJvm {
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_PRIVATE = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_LOCAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR_WARNING = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<KtAnnotationEntry> OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitJvmOverloadsOnConstructorsOfAnnotationClasses);
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_ANNOTATION_MANGLED_FUNCTION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> OVERLOADS_ANNOTATION_HIDDEN_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
@@ -113,10 +113,8 @@ public interface ErrorsJvm {
|
||||
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, DeclarationDescriptor, String> TARGET6_INTERFACE_INHERITANCE = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactoryForDeprecation0.create(LanguageFeature.DefaultMethodsCallFromJava6TargetError);
|
||||
DiagnosticFactoryForDeprecation0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactoryForDeprecation0.create(LanguageFeature.DefaultMethodsCallFromJava6TargetError);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> INLINE_FROM_HIGHER_PLATFORM = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, String, String> INLINE_FROM_HIGHER_PLATFORM_WARNING = DiagnosticFactory2.create(WARNING);
|
||||
@@ -175,13 +173,11 @@ public interface ErrorsJvm {
|
||||
DiagnosticFactory1<PsiElement, String> SUSPENSION_POINT_INSIDE_MONITOR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> SUSPENSION_POINT_INSIDE_CRITICAL_SECTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> CONCURRENT_HASH_MAP_CONTAINS_OPERATOR = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<PsiElement> CONCURRENT_HASH_MAP_CONTAINS_OPERATOR = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitConcurrentHashMapContains);
|
||||
|
||||
DiagnosticFactory0<KtNamedFunction> TAILREC_WITH_DEFAULTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<PsiElement> SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation0<PsiElement> SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL = DiagnosticFactoryForDeprecation0.create(LanguageFeature.ProhibitSpreadOnSignaturePolymorphicCall);
|
||||
|
||||
DiagnosticFactory0<PsiElement> FUNCTION_DELEGATE_MEMBER_NAME_CLASH = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user