Treat absence of version in SinceKotlinInfo as infinite version
This may be needed in the future to make some declarations erroneous for all versions of compilers
This commit is contained in:
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.WrongResolutionToClassifier;
|
||||
import org.jetbrains.kotlin.resolve.checkers.HeaderImplDeclarationChecker;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfo;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -81,8 +82,8 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATION_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, String, Pair<LanguageVersion, String>> SINCE_KOTLIN_INFO_DEPRECATION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, String, Pair<LanguageVersion, String>> SINCE_KOTLIN_INFO_DEPRECATION_ERROR = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, SinceKotlinInfo.Version, Pair<LanguageVersion, String>> SINCE_KOTLIN_INFO_DEPRECATION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, SinceKotlinInfo.Version, Pair<LanguageVersion, String>> SINCE_KOTLIN_INFO_DEPRECATION_ERROR = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> API_NOT_AVAILABLE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
|
||||
+16
-3
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression;
|
||||
import org.jetbrains.kotlin.psi.KtTypeConstraint;
|
||||
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfo;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
@@ -321,7 +322,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(DEPRECATION, "''{0}'' is deprecated. {1}", DEPRECATION_RENDERER, STRING);
|
||||
MAP.put(DEPRECATION_ERROR, "Using ''{0}'' is an error. {1}", DEPRECATION_RENDERER, STRING);
|
||||
|
||||
DiagnosticParameterRenderer<Pair<LanguageVersion, String>> sinceKotlinInfoRenderer = new DiagnosticParameterRenderer<Pair<LanguageVersion, String>>() {
|
||||
DiagnosticParameterRenderer<Pair<LanguageVersion, String>> sinceKotlinInfoMessage = new DiagnosticParameterRenderer<Pair<LanguageVersion, String>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull Pair<LanguageVersion, String> pair, @NotNull RenderingContext renderingContext) {
|
||||
@@ -329,8 +330,20 @@ public class DefaultErrorMessages {
|
||||
return pair.getFirst().getVersionString() + (message != null ? ". " + message : "");
|
||||
}
|
||||
};
|
||||
MAP.put(SINCE_KOTLIN_INFO_DEPRECATION, "''{0}'' is only supported since Kotlin {1} and should not be used in Kotlin {2}", DEPRECATION_RENDERER, STRING, sinceKotlinInfoRenderer);
|
||||
MAP.put(SINCE_KOTLIN_INFO_DEPRECATION_ERROR, "''{0}'' is only available since Kotlin {1} and cannot be used in Kotlin {2}", DEPRECATION_RENDERER, STRING, sinceKotlinInfoRenderer);
|
||||
MAP.put(SINCE_KOTLIN_INFO_DEPRECATION, "''{0}''{1} should not be used in Kotlin {2}", DEPRECATION_RENDERER, new DiagnosticParameterRenderer<SinceKotlinInfo.Version>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull SinceKotlinInfo.Version obj, @NotNull RenderingContext renderingContext) {
|
||||
return obj.equals(SinceKotlinInfo.Version.INFINITY) ? "" : " is only supported since Kotlin " + obj.asString() + " and";
|
||||
}
|
||||
}, sinceKotlinInfoMessage);
|
||||
MAP.put(SINCE_KOTLIN_INFO_DEPRECATION_ERROR, "''{0}''{1} cannot be used in Kotlin {2}", DEPRECATION_RENDERER, new DiagnosticParameterRenderer<SinceKotlinInfo.Version>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull SinceKotlinInfo.Version obj, @NotNull RenderingContext renderingContext) {
|
||||
return obj.equals(SinceKotlinInfo.Version.INFINITY) ? "" : " is only available since Kotlin " + obj.asString() + " and";
|
||||
}
|
||||
}, sinceKotlinInfoMessage);
|
||||
|
||||
MAP.put(API_NOT_AVAILABLE, "This declaration is only available since Kotlin {0} and cannot be used with the specified API version {1}", STRING, STRING);
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ private data class DeprecatedBySinceKotlinInfo(
|
||||
}
|
||||
}
|
||||
|
||||
val sinceKotlinVersion: String
|
||||
get() = sinceKotlinInfo.version.asString()
|
||||
val sinceKotlinVersion: SinceKotlinInfo.Version
|
||||
get() = sinceKotlinInfo.version
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.getDeprecations(languageVersionSettings: LanguageVersionSettings): List<Deprecation> {
|
||||
|
||||
Reference in New Issue
Block a user