Forward compatibility hacks for Result.{success, failure}
Don't mangled functions annotated with @JvmName.
Annotate 'Result.success' and 'Result.failure' with @JvmName and
@Suppress("INAPPLICABLE_JVM_NAME").
NB this would require bootstrap.
This commit is contained in:
@@ -10,6 +10,7 @@ package kotlin
|
||||
import kotlin.contracts.*
|
||||
import kotlin.internal.InlineOnly
|
||||
import kotlin.jvm.JvmField
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
/**
|
||||
* A discriminated union that encapsulates a successful outcome with a value of type [T]
|
||||
@@ -84,14 +85,18 @@ public inline class Result<out T> @PublishedApi internal constructor(
|
||||
/**
|
||||
* Returns an instance that encapsulates the given [value] as successful value.
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@InlineOnly
|
||||
@JvmName("success")
|
||||
public inline fun <T> success(value: T): Result<T> =
|
||||
Result(value)
|
||||
|
||||
/**
|
||||
* Returns an instance that encapsulates the given [Throwable] [exception] as failure.
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@InlineOnly
|
||||
@JvmName("failure")
|
||||
public inline fun <T> failure(exception: Throwable): Result<T> =
|
||||
Result(createFailure(exception))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user