Annotate inline use and useLines with RequireKotlin

Compiler version 1.2 is required to use 'use' and inline functions from stdlib that call it.
This commit is contained in:
Ilya Gorbunov
2017-10-12 08:10:45 +03:00
parent cc150ca832
commit 863727955f
4 changed files with 5 additions and 0 deletions
@@ -72,5 +72,6 @@ private fun getJavaVersion(): Int {
* The function usages are validated to have literal argument values.
*/
@PublishedApi
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
internal fun apiVersionIsAtLeast(major: Int, minor: Int, patch: Int) =
KotlinVersion.CURRENT.isAtLeast(major, minor, patch)
@@ -29,6 +29,7 @@ import kotlin.internal.*
* @return the result of [block] function invoked on this resource.
*/
@InlineOnly
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
public inline fun <T : Closeable?, R> T.use(block: (T) -> R): R {
var exception: Throwable? = null
try {
@@ -6,6 +6,7 @@ package kotlin.io
import java.io.*
import java.util.*
import java.nio.charset.Charset
import kotlin.internal.*
/**
@@ -195,5 +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.
* @return the value returned by [block].
*/
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
public inline fun <T> File.useLines(charset: Charset = Charsets.UTF_8, block: (Sequence<String>) -> T): T =
bufferedReader(charset).use { block(it.lineSequence()) }
@@ -43,6 +43,7 @@ public fun Reader.readLines(): List<String> {
* the processing is complete.
* @return the value returned by [block].
*/
@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
public inline fun <T> Reader.useLines(block: (Sequence<String>) -> T): T =
buffered().use { block(it.lineSequence()) }