From e92e7c6f808a0cb3d008c76d96a99093a284a4c2 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 28 Feb 2018 15:59:47 +0100 Subject: [PATCH] Do not report RequireKotlin-related diagnostics in snapshot compilers Otherwise it's difficult to use a newly added API annotated with RequireKotlin with the latest, not yet released, version. For example, suppose there's a new function added in kotlin-stdlib, since Kotlin 1.3, which requires 1.3 (Kotlin < 1.3 is supposed to report an error on usages): @SinceKotlin("1.3") @RequireKotlin("1.3", COMPILER_VERSION, message = ...) fun foo() {} Until Kotlin 1.3 is released, the latest available compiler in Maven has the version 1.3-SNAPSHOT, which is _less_ than 1.3 according to Maven rules which are used in getDeprecationByVersionRequirement. Therefore, errors will be reported on usages of foo, and there's no Kotlin compiler version which can be used to verify if the function works correctly, which is inconvenient. Since SNAPSHOT versions are effectively "pre-release" in a way, it's OK for them to skip reporting these diagnostics --- .../src/org/jetbrains/kotlin/resolve/deprecationUtil.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt index 84662198ec5..61e69182072 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt @@ -345,7 +345,7 @@ class DeprecationResolver( ProtoBuf.VersionRequirement.VersionKind.API_VERSION -> languageVersionSettings.apiVersion.version ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION -> - KotlinCompilerVersion.getVersion()?.let(::createVersion) + KotlinCompilerVersion.getVersion()?.takeIf { "SNAPSHOT" !in it }?.let(::createVersion) else -> null } if (currentVersion != null && currentVersion < requiredVersion) {