Sanitize compiler version for version requirement checks

Strip everything after (and including) the first '-' character.

The previous approach of skipping the checks if "SNAPSHOT" is in the
version, is subsumed by the new one because "1.2-SNAPSHOT" now becomes
"1.2" with regards to the version requirement checks, which allows the
compiler to use the 1.2-only API
This commit is contained in:
Alexander Udalov
2018-03-26 16:56:25 +02:00
parent b78869ecfc
commit 5d9348eea1
@@ -345,7 +345,7 @@ class DeprecationResolver(
ProtoBuf.VersionRequirement.VersionKind.API_VERSION ->
languageVersionSettings.apiVersion.version
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION ->
KotlinCompilerVersion.getVersion()?.takeIf { "SNAPSHOT" !in it }?.let(::createVersion)
KotlinCompilerVersion.getVersion()?.substringBefore('-')?.let(::createVersion)
else -> null
}
if (currentVersion != null && currentVersion < requiredVersion) {