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
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user