Drop deprecations and tighten up left ones.
This commit is contained in:
@@ -20,7 +20,7 @@ public operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = put(key,
|
||||
* getOrPut is not supported on [ConcurrentMap] since it cannot be implemented correctly in terms of concurrency.
|
||||
* Use [concurrentGetOrPut] instead, or cast this to a [MutableMap] if you want to sacrifice the concurrent-safety.
|
||||
*/
|
||||
@Deprecated("Use concurrentGetOrPut instead or cast this map to MutableMap.")
|
||||
@Deprecated("Use concurrentGetOrPut instead or cast this map to MutableMap.", level = DeprecationLevel.ERROR)
|
||||
public inline fun <K, V> ConcurrentMap<K, V>.getOrPut(key: K, defaultValue: () -> V): Nothing =
|
||||
throw UnsupportedOperationException("getOrPut is not supported on ConcurrentMap.")
|
||||
|
||||
|
||||
@@ -61,10 +61,7 @@ public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStrea
|
||||
* @param bufferSize the buffer size to use.
|
||||
*/
|
||||
public fun InputStream.buffered(bufferSize: Int = defaultBufferSize): InputStream
|
||||
= if (this is BufferedInputStream)
|
||||
this
|
||||
else
|
||||
BufferedInputStream(this, bufferSize)
|
||||
= if (this is BufferedInputStream) this else BufferedInputStream(this, bufferSize)
|
||||
|
||||
/** Creates a reader on this input stream using UTF-8 or the specified [charset]. */
|
||||
public fun InputStream.reader(charset: Charset = Charsets.UTF_8): InputStreamReader = InputStreamReader(this, charset)
|
||||
|
||||
@@ -48,12 +48,6 @@ public fun String.reader(): StringReader = StringReader(this)
|
||||
*/
|
||||
public fun BufferedReader.lineSequence(): Sequence<String> = LinesSequence(this).constrainOnce()
|
||||
|
||||
@Deprecated("Use lineSequence() instead to avoid conflict with JDK8 lines() method.", ReplaceWith("lineSequence()"))
|
||||
public fun BufferedReader.lines(): Sequence<String> = lineSequence()
|
||||
|
||||
@Deprecated("Use lineSequence() function which returns Sequence<String>")
|
||||
public fun BufferedReader.lineIterator(): Iterator<String> = lineSequence().iterator()
|
||||
|
||||
private class LinesSequence(private val reader: BufferedReader) : Sequence<String> {
|
||||
override public fun iterator(): Iterator<String> {
|
||||
return object : Iterator<String> {
|
||||
|
||||
@@ -211,16 +211,6 @@ public class FileTreeWalk(private val start: File,
|
||||
return FileTreeWalk(start, direction, enter, leave, function, filter, maxDepth)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets tree filter [predicate].
|
||||
* Tree filter [predicate] function is called before visiting files and entering directories.
|
||||
* If it returns `false`, file is not visited, directory is not entered and all its content is also not visited.
|
||||
* If it returns `true`, everything goes in the regular way.
|
||||
*/
|
||||
@Deprecated("Use treeFilter instead", ReplaceWith("treeFilter(predicate)"))
|
||||
public fun filter(predicate: (File) -> Boolean): FileTreeWalk {
|
||||
return FileTreeWalk(start, direction, enter, leave, fail, predicate, maxDepth)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets tree filter [predicate].
|
||||
@@ -295,7 +285,7 @@ public fun File.walkBottomUp(): FileTreeWalk = walk(FileWalkDirection.BOTTOM_UP)
|
||||
*
|
||||
* @param function the function to call on each file.
|
||||
*/
|
||||
@Deprecated("It's recommended to use walkTopDown() / walkBottomUp()", ReplaceWith("walkTopDown().forEach(function)"))
|
||||
@Deprecated("It's recommended to use walkTopDown() / walkBottomUp()", ReplaceWith("walkTopDown().forEach(function)"), DeprecationLevel.ERROR)
|
||||
public fun File.recurse(function: (File) -> Unit): Unit {
|
||||
walkTopDown().forEach(function)
|
||||
}
|
||||
|
||||
@@ -54,31 +54,10 @@ public val File.directory: File
|
||||
/**
|
||||
* Returns parent of this abstract path name, or `null` if it has no parent.
|
||||
*/
|
||||
@Deprecated("Use parentFile", ReplaceWith("parentFile"))
|
||||
@Deprecated("Use parentFile", ReplaceWith("parentFile"), DeprecationLevel.ERROR)
|
||||
public val File.parent: File?
|
||||
get() = parentFile
|
||||
|
||||
/**
|
||||
* Returns the canonical path of this file.
|
||||
*/
|
||||
@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("canonicalPath"), level = DeprecationLevel.HIDDEN)
|
||||
public val File.canonicalPath: String
|
||||
get() = getCanonicalPath()
|
||||
|
||||
/**
|
||||
* Returns the file name.
|
||||
*/
|
||||
@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("name"), level = DeprecationLevel.HIDDEN)
|
||||
public val File.name: String
|
||||
get() = getName()
|
||||
|
||||
/**
|
||||
* Returns the file path.
|
||||
*/
|
||||
@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("path"), level = DeprecationLevel.HIDDEN)
|
||||
public val File.path: String
|
||||
get() = getPath()
|
||||
|
||||
/**
|
||||
* Returns the extension of this file (not including the dot), or an empty string if it doesn't have one.
|
||||
*/
|
||||
|
||||
@@ -117,7 +117,7 @@ public class Regex internal constructor(private val nativePattern: Pattern) {
|
||||
/** Indicates whether the regular expression can find at least one match in the specified [input]. */
|
||||
public fun containsMatchIn(input: CharSequence): Boolean = nativePattern.matcher(input).find()
|
||||
|
||||
@Deprecated("Use containsMatchIn() or 'in' operator instead.", ReplaceWith("this in input"))
|
||||
@Deprecated("Use containsMatchIn() or 'in' operator instead.", ReplaceWith("this in input"), DeprecationLevel.ERROR)
|
||||
public fun hasMatch(input: CharSequence): Boolean = containsMatchIn(input)
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public class Regex internal constructor(private val nativePattern: Pattern) {
|
||||
*/
|
||||
public fun find(input: CharSequence, startIndex: Int = 0): MatchResult? = nativePattern.matcher(input).findNext(startIndex, input)
|
||||
|
||||
@Deprecated("Use find() instead.", ReplaceWith("find(input, startIndex)"))
|
||||
@Deprecated("Use find() instead.", ReplaceWith("find(input, startIndex)"), DeprecationLevel.ERROR)
|
||||
public fun match(input: CharSequence, startIndex: Int = 0): MatchResult? = find(input, startIndex)
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ public class Regex internal constructor(private val nativePattern: Pattern) {
|
||||
*/
|
||||
public fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = sequence({ find(input, startIndex) }, { match -> match.next() })
|
||||
|
||||
@Deprecated("Use findAll() instead.", ReplaceWith("findAll(input, startIndex)"))
|
||||
@Deprecated("Use findAll() instead.", ReplaceWith("findAll(input, startIndex)"), DeprecationLevel.ERROR)
|
||||
public fun matchAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = findAll(input, startIndex)
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ package kotlin
|
||||
|
||||
private object _Assertions
|
||||
|
||||
@Deprecated("Must be public to make assert() inlinable")
|
||||
@Deprecated("Not supposed to be used directly, exposed to make assert() inlinable.")
|
||||
public val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus()
|
||||
|
||||
/**
|
||||
@@ -22,6 +22,7 @@ public fun assert(value: Boolean) {
|
||||
*/
|
||||
@Deprecated("Use assert with lazy message instead.", ReplaceWith("assert(value) { message }"))
|
||||
public fun assert(value: Boolean, message: Any = "Assertion failed") {
|
||||
@Suppress("DEPRECATION")
|
||||
if (ASSERTIONS_ENABLED) {
|
||||
if (!value) {
|
||||
throw AssertionError(message)
|
||||
@@ -34,6 +35,7 @@ public fun assert(value: Boolean, message: Any = "Assertion failed") {
|
||||
* and runtime assertions have been enabled on the JVM using the *-ea* JVM option.
|
||||
*/
|
||||
public inline fun assert(value: Boolean, lazyMessage: () -> Any) {
|
||||
@Suppress("DEPRECATION")
|
||||
if (ASSERTIONS_ENABLED) {
|
||||
if (!value) {
|
||||
val message = lazyMessage()
|
||||
|
||||
@@ -25,7 +25,7 @@ import kotlin.reflect.KClass
|
||||
* @property exceptionClasses the list of checked exception classes that may be thrown by the function.
|
||||
*/
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Deprecated("Use 'kotlin.jvm.Throws' instead", ReplaceWith("kotlin.jvm.Throws"))
|
||||
@Deprecated("Use 'kotlin.jvm.Throws' instead", ReplaceWith("kotlin.jvm.Throws"), DeprecationLevel.ERROR)
|
||||
public annotation class throws(public vararg val exceptionClasses: KClass<out Throwable>)
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,9 +19,6 @@ package kotlin
|
||||
|
||||
import java.util.Comparator
|
||||
|
||||
@Deprecated("Use compareValuesBy", ReplaceWith("compareValuesBy(a, b, *selectors)"), level = DeprecationLevel.HIDDEN)
|
||||
public fun <T> compareValuesByNullable(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int = compareValuesBy(a, b, *selectors)
|
||||
|
||||
/**
|
||||
* Compares two values using the specified functions [selectors] to calculate the result of the comparison.
|
||||
* The functions are called sequentially, receive the given values [a] and [b] and return [Comparable]
|
||||
|
||||
Reference in New Issue
Block a user