[K/N] Make assert functions experimental with ExperimentalNativeApi
This commit is contained in:
committed by
Space Team
parent
245ef256bd
commit
b6c2ce2dc8
@@ -5,11 +5,14 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
/**
|
||||
* Throws an [AssertionError] if the [value] is false
|
||||
* and runtime assertions have been enabled during compilation.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@ExperimentalNativeApi
|
||||
public inline fun assert(value: Boolean) {
|
||||
assert(value) { "Assertion failed" }
|
||||
}
|
||||
@@ -18,6 +21,7 @@ public inline fun assert(value: Boolean) {
|
||||
* Throws an [AssertionError] calculated by [lazyMessage] if the [value] is false
|
||||
* and runtime assertions have been enabled during compilation.
|
||||
*/
|
||||
@ExperimentalNativeApi
|
||||
public inline fun assert(value: Boolean, lazyMessage: () -> Any) {
|
||||
if (!value) {
|
||||
val message = lazyMessage()
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
public class Continuation0(block: () -> Unit,
|
||||
private val invoker: CPointer<CFunction<(COpaquePointer?) -> Unit>>,
|
||||
private val singleShot: Boolean = false): Function0<Unit> {
|
||||
@@ -32,7 +33,7 @@ public class Continuation0(block: () -> Unit,
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
public class Continuation1<T1>(
|
||||
block: (p1: T1) -> Unit,
|
||||
private val invoker: CPointer<CFunction<(COpaquePointer?) -> Unit>>,
|
||||
@@ -64,7 +65,7 @@ public class Continuation1<T1>(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
public class Continuation2<T1, T2>(
|
||||
block: (p1: T1, p2: T2) -> Unit,
|
||||
private val invoker: CPointer<CFunction<(COpaquePointer?) -> Unit>>,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.Frozen
|
||||
|
||||
@FreezingIsDeprecated
|
||||
@@ -84,6 +85,7 @@ internal object INITIALIZING {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
@FreezingIsDeprecated
|
||||
@Frozen
|
||||
internal class AtomicLazyImpl<out T>(initializer: () -> T) : Lazy<T> {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.Frozen
|
||||
|
||||
@ThreadLocal
|
||||
@@ -14,7 +15,7 @@ private object CurrentThread {
|
||||
}
|
||||
|
||||
@Frozen
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
internal class Lock {
|
||||
private val locker_ = AtomicInt(0)
|
||||
private val reenterCount_ = AtomicInt(0)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
@@ -42,6 +43,7 @@ public class MutableData constructor(capacity: Int = 16) {
|
||||
private val lock = Lock()
|
||||
|
||||
private fun resizeDataLocked(newSize: Int): Int {
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
assert(newSize >= size)
|
||||
if (newSize > buffer.size) {
|
||||
val actualSize = maxOf(buffer.size * 3 / 2 + 1, newSize)
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
@file:Suppress("DEPRECATION") // Char.toInt()
|
||||
package kotlin.text.regex
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
/**
|
||||
* This is base class for special tokens like character classes and quantifiers.
|
||||
*/
|
||||
@@ -516,6 +518,7 @@ internal class Lexer(val patternString: String, flags: Int) {
|
||||
|
||||
/** Process [lookAhead] in assumption that it's quantifier. */
|
||||
private fun processQuantifier(): Quantifier {
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
assert(lookAhead == '{'.toInt())
|
||||
val sb = StringBuilder(4)
|
||||
var min = -1
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
package kotlin.text.regex
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
/**
|
||||
* The node which marks end of the particular group.
|
||||
*/
|
||||
@@ -45,6 +47,7 @@ open internal class FSet(val groupIndex: Int) : SimpleSet() {
|
||||
|
||||
override fun processSecondPass(): FSet {
|
||||
val result = super.processSecondPass()
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
assert(result == this)
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
package kotlin.text.regex
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
/**
|
||||
* Represents group, which is alternation of other subexpression.
|
||||
* One should think about "group" in this model as JointSet opening group and corresponding FSet closing group.
|
||||
@@ -73,6 +75,7 @@ open internal class JointSet(children: List<AbstractSet>, fSet: FSet) : Abstract
|
||||
val fSet = this.fSet
|
||||
if (!fSet.secondPassVisited) {
|
||||
val newFSet = fSet.processSecondPass()
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
assert(newFSet == fSet)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
package kotlin.text.regex
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
/**
|
||||
* Group node over subexpression without alternations.
|
||||
*/
|
||||
@@ -86,6 +88,7 @@ open internal class SingleSet(var kid: AbstractSet, fSet: FSet) : JointSet(listO
|
||||
override fun processSecondPass(): AbstractSet {
|
||||
if (secondPassVisited) {
|
||||
if (fSet.isBackReferenced) {
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
assert(backReferencedSet != null) // secondPassVisited
|
||||
return backReferencedSet!!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user