Minor: improve message from future for use and useLines
Annotate RequireKotlin and apiVersionIsAtLeast with SinceKotlin
This commit is contained in:
@@ -95,6 +95,7 @@ internal annotation class AccessibleLateinitPropertyLiteral
|
|||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.TYPEALIAS)
|
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.TYPEALIAS)
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
|
@SinceKotlin("1.2")
|
||||||
internal annotation class RequireKotlin(
|
internal annotation class RequireKotlin(
|
||||||
val version: String,
|
val version: String,
|
||||||
val message: String = "",
|
val message: String = "",
|
||||||
@@ -106,6 +107,7 @@ internal annotation class RequireKotlin(
|
|||||||
/**
|
/**
|
||||||
* The kind of the version that is required by [RequireKotlin].
|
* The kind of the version that is required by [RequireKotlin].
|
||||||
*/
|
*/
|
||||||
|
@SinceKotlin("1.2")
|
||||||
internal enum class RequireKotlinVersionKind {
|
internal enum class RequireKotlinVersionKind {
|
||||||
LANGUAGE_VERSION,
|
LANGUAGE_VERSION,
|
||||||
COMPILER_VERSION,
|
COMPILER_VERSION,
|
||||||
|
|||||||
@@ -72,6 +72,6 @@ private fun getJavaVersion(): Int {
|
|||||||
* The function usages are validated to have literal argument values.
|
* The function usages are validated to have literal argument values.
|
||||||
*/
|
*/
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
|
@SinceKotlin("1.2")
|
||||||
internal fun apiVersionIsAtLeast(major: Int, minor: Int, patch: Int) =
|
internal fun apiVersionIsAtLeast(major: Int, minor: Int, patch: Int) =
|
||||||
KotlinVersion.CURRENT.isAtLeast(major, minor, patch)
|
KotlinVersion.CURRENT.isAtLeast(major, minor, patch)
|
||||||
@@ -29,7 +29,7 @@ import kotlin.internal.*
|
|||||||
* @return the result of [block] function invoked on this resource.
|
* @return the result of [block] function invoked on this resource.
|
||||||
*/
|
*/
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
|
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION, message = "Requires newer compiler version to be inlined correctly.")
|
||||||
public inline fun <T : Closeable?, R> T.use(block: (T) -> R): R {
|
public inline fun <T : Closeable?, R> T.use(block: (T) -> R): R {
|
||||||
var exception: Throwable? = null
|
var exception: Throwable? = null
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -196,6 +196,6 @@ public fun File.readLines(charset: Charset = Charsets.UTF_8): List<String> {
|
|||||||
* @param charset character set to use. By default uses UTF-8 charset.
|
* @param charset character set to use. By default uses UTF-8 charset.
|
||||||
* @return the value returned by [block].
|
* @return the value returned by [block].
|
||||||
*/
|
*/
|
||||||
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
|
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION, message = "Requires newer compiler version to be inlined correctly.")
|
||||||
public inline fun <T> File.useLines(charset: Charset = Charsets.UTF_8, block: (Sequence<String>) -> T): T =
|
public inline fun <T> File.useLines(charset: Charset = Charsets.UTF_8, block: (Sequence<String>) -> T): T =
|
||||||
bufferedReader(charset).use { block(it.lineSequence()) }
|
bufferedReader(charset).use { block(it.lineSequence()) }
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public fun Reader.readLines(): List<String> {
|
|||||||
* the processing is complete.
|
* the processing is complete.
|
||||||
* @return the value returned by [block].
|
* @return the value returned by [block].
|
||||||
*/
|
*/
|
||||||
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
|
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION, message = "Requires newer compiler version to be inlined correctly.")
|
||||||
public inline fun <T> Reader.useLines(block: (Sequence<String>) -> T): T =
|
public inline fun <T> Reader.useLines(block: (Sequence<String>) -> T): T =
|
||||||
buffered().use { block(it.lineSequence()) }
|
buffered().use { block(it.lineSequence()) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user