mirror of
https://github.com/zhanghai/MaterialFiles
synced 2024-07-08 19:45:51 +00:00
[Refactor] Remove Kotlin use workaround since it now has contract.
See also
941de655c4
.
This commit is contained in:
parent
8b7d9eaf9f
commit
30164e073c
|
@ -5,30 +5,6 @@
|
|||
|
||||
package me.zhanghai.android.files.compat
|
||||
|
||||
import java.io.Closeable
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.comparisons.reversed as kotlinReversed
|
||||
import kotlin.io.use as kotlinUse
|
||||
import kotlin.use as kotlinUse
|
||||
|
||||
// @see https://youtrack.jetbrains.com/issue/KT-35216
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun <T : AutoCloseable?, R> T.use(block: (T) -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return kotlinUse(block)
|
||||
}
|
||||
|
||||
// @see https://youtrack.jetbrains.com/issue/KT-35216
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun <T : Closeable?, R> T.use(block: (T) -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return kotlinUse(block)
|
||||
}
|
||||
|
||||
fun <T> Comparator<T>.reversedCompat(): Comparator<T> = kotlinReversed()
|
||||
|
|
|
@ -16,7 +16,6 @@ import java8.nio.file.NotLinkException
|
|||
import java8.nio.file.Path
|
||||
import me.zhanghai.android.files.R
|
||||
import me.zhanghai.android.files.compat.toJavaSeekableByteChannel
|
||||
import me.zhanghai.android.files.compat.use
|
||||
//#ifdef NONFREE
|
||||
import me.zhanghai.android.files.nonfree.RarArchiveEntry
|
||||
import me.zhanghai.android.files.nonfree.RarFile
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.os.Parcelable
|
|||
import android.provider.DocumentsContract
|
||||
import java8.nio.file.attribute.BasicFileAttributeView
|
||||
import java8.nio.file.attribute.FileTime
|
||||
import me.zhanghai.android.files.compat.use
|
||||
import me.zhanghai.android.files.provider.content.resolver.ResolverException
|
||||
import me.zhanghai.android.files.provider.content.resolver.getInt
|
||||
import me.zhanghai.android.files.provider.content.resolver.getLong
|
||||
|
|
Loading…
Reference in New Issue
Block a user