Make all assert inline. Field _Assertions.ENABLED instead of property ASSERTIONS_ENABLED
This commit is contained in:
@@ -60,7 +60,7 @@ public class FileTreeWalk private constructor(
|
|||||||
/** Abstract class that encapsulates directory visiting in some order, beginning from a given [rootDir] */
|
/** Abstract class that encapsulates directory visiting in some order, beginning from a given [rootDir] */
|
||||||
private abstract class DirectoryState(rootDir: File): WalkState(rootDir) {
|
private abstract class DirectoryState(rootDir: File): WalkState(rootDir) {
|
||||||
init {
|
init {
|
||||||
if (ASSERTIONS_ENABLED)
|
if (_Assertions.ENABLED)
|
||||||
assert(rootDir.isDirectory) { "rootDir must be verified to be directory beforehand." }
|
assert(rootDir.isDirectory) { "rootDir must be verified to be directory beforehand." }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ public class FileTreeWalk private constructor(
|
|||||||
private var visited: Boolean = false
|
private var visited: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (ASSERTIONS_ENABLED)
|
if (_Assertions.ENABLED)
|
||||||
assert(rootFile.isFile) { "rootFile must be verified to be file beforehand." }
|
assert(rootFile.isFile) { "rootFile must be verified to be file beforehand." }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,17 @@
|
|||||||
package kotlin
|
package kotlin
|
||||||
|
|
||||||
|
|
||||||
private object _Assertions
|
internal object _Assertions {
|
||||||
|
@JvmField
|
||||||
internal val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus()
|
internal val ENABLED: Boolean = javaClass.desiredAssertionStatus()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an [AssertionError] if the [value] is false
|
* Throws an [AssertionError] if the [value] is false
|
||||||
* and runtime assertions have been enabled on the JVM using the *-ea* JVM option.
|
* and runtime assertions have been enabled on the JVM using the *-ea* JVM option.
|
||||||
*/
|
*/
|
||||||
public fun assert(value: Boolean) {
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun assert(value: Boolean) {
|
||||||
assert(value) { "Assertion failed" }
|
assert(value) { "Assertion failed" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ public fun assert(value: Boolean) {
|
|||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun assert(value: Boolean, lazyMessage: () -> Any) {
|
public inline fun assert(value: Boolean, lazyMessage: () -> Any) {
|
||||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||||
if (ASSERTIONS_ENABLED) {
|
if (_Assertions.ENABLED) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
val message = lazyMessage()
|
val message = lazyMessage()
|
||||||
throw AssertionError(message)
|
throw AssertionError(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user