Introduce BinaryVersion.isCompatible()

To decrease the chance to mix up the receiver and the first argument when
checking version compatibility
This commit is contained in:
Alexander Udalov
2015-12-28 16:39:17 +03:00
parent 04d335db15
commit 9552accaec
17 changed files with 31 additions and 56 deletions
@@ -31,6 +31,8 @@ abstract class BinaryVersion protected constructor(
val patch: Int,
val rest: List<Int>
) {
abstract fun isCompatible(): Boolean
fun toArray(): IntArray =
intArrayOf(major, minor, patch, *rest.toIntArray())
@@ -40,7 +42,7 @@ abstract class BinaryVersion protected constructor(
*
* @param ourVersion the version of this format in the current compiler
*/
fun isCompatibleTo(ourVersion: BinaryVersion): Boolean {
protected fun isCompatibleTo(ourVersion: BinaryVersion): Boolean {
return if (major == 0) ourVersion.major == 0 && minor == ourVersion.minor
else major == ourVersion.major && minor <= ourVersion.minor
}