From 079a2dfe1e6de076b9df92b61caad71ca0740646 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Sun, 16 Aug 2020 23:53:17 +0300 Subject: [PATCH] Move EventOccurrencesRange class to :core:descriptors.common module --- .../description/EventOccurrencesRange.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) rename {compiler/resolution => core/descriptors.common}/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt (70%) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt b/core/descriptors.common/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt similarity index 70% rename from compiler/resolution/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt rename to core/descriptors.common/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt index 0997a0d4969..a3f36f07425 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt +++ b/core/descriptors.common/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -31,9 +31,11 @@ enum class EventOccurrencesRange(private val left: Int, private val right: Int) else -> throw IllegalArgumentException() } - fun or(x: EventOccurrencesRange, y: EventOccurrencesRange): EventOccurrencesRange = fromRange(min(x.left, y.left), max(x.right, y.right)) + fun or(x: EventOccurrencesRange, y: EventOccurrencesRange): EventOccurrencesRange = + fromRange(min(x.left, y.left), max(x.right, y.right)) - fun plus(x: EventOccurrencesRange, y: EventOccurrencesRange): EventOccurrencesRange = fromRange(x.left + y.left, x.right + y.right) + fun plus(x: EventOccurrencesRange, y: EventOccurrencesRange): EventOccurrencesRange = + fromRange(x.left + y.left, x.right + y.right) } infix fun or(other: EventOccurrencesRange): EventOccurrencesRange = Companion.or(this, other) @@ -41,5 +43,8 @@ enum class EventOccurrencesRange(private val left: Int, private val right: Int) operator fun contains(other: EventOccurrencesRange): Boolean = left <= other.left && other.right <= right } -fun EventOccurrencesRange.isDefinitelyVisited(): Boolean = this == EventOccurrencesRange.EXACTLY_ONCE || this == EventOccurrencesRange.AT_LEAST_ONCE || this == EventOccurrencesRange.MORE_THAN_ONCE -fun EventOccurrencesRange.canBeRevisited(): Boolean = this == EventOccurrencesRange.UNKNOWN || this == EventOccurrencesRange.AT_LEAST_ONCE || this == EventOccurrencesRange.MORE_THAN_ONCE +fun EventOccurrencesRange.isDefinitelyVisited(): Boolean = + this == EventOccurrencesRange.EXACTLY_ONCE || this == EventOccurrencesRange.AT_LEAST_ONCE || this == EventOccurrencesRange.MORE_THAN_ONCE + +fun EventOccurrencesRange.canBeRevisited(): Boolean = + this == EventOccurrencesRange.UNKNOWN || this == EventOccurrencesRange.AT_LEAST_ONCE || this == EventOccurrencesRange.MORE_THAN_ONCE