Rename SuccessOrFailure to Result and hide Failure from ABI

* The members of Result are isSuccess, isFailure, exceptionOrNull, getOrNull
* The rest of API is implemented via inline-only extensions
* There are two internal functions to hide detailed mechanics of an internal
  Result.Failure class: createFailure and throwOnFailure
* Result.toString is explicit: either Success(v) or Failure(x)

See KT-26538
This commit is contained in:
Roman Elizarov
2018-09-09 11:34:31 +03:00
parent 69ee88871f
commit e2713501ce
81 changed files with 968 additions and 612 deletions
@@ -64,7 +64,7 @@ abstract class AbstractCoroutineCodegen(
if (languageVersionSettings.isReleaseCoroutines()) if (languageVersionSettings.isReleaseCoroutines())
createImplMethod( createImplMethod(
INVOKE_SUSPEND_METHOD_NAME, INVOKE_SUSPEND_METHOD_NAME,
"result" to classDescriptor.module.getSuccessOrFailure(classDescriptor.builtIns.anyType) "result" to classDescriptor.module.getResult(classDescriptor.builtIns.anyType)
) )
else else
createImplMethod( createImplMethod(
@@ -759,11 +759,11 @@ private fun InstructionAdapter.generateResumeWithExceptionCheck(isReleaseCorouti
val noExceptionLabel = Label() val noExceptionLabel = Label()
if (isReleaseCoroutines) { if (isReleaseCoroutines) {
instanceOf(AsmTypes.SUCCESS_OR_FAILURE_FAILURE) instanceOf(AsmTypes.RESULT_FAILURE)
ifeq(noExceptionLabel) ifeq(noExceptionLabel)
// TODO: do we need this checkcast? // TODO: do we need this checkcast?
checkcast(AsmTypes.SUCCESS_OR_FAILURE_FAILURE) checkcast(AsmTypes.RESULT_FAILURE)
getfield(AsmTypes.SUCCESS_OR_FAILURE_FAILURE.internalName, "exception", AsmTypes.JAVA_THROWABLE_TYPE.descriptor) getfield(AsmTypes.RESULT_FAILURE.internalName, "exception", AsmTypes.JAVA_THROWABLE_TYPE.descriptor)
} else { } else {
ifnull(noExceptionLabel) ifnull(noExceptionLabel)
} }
@@ -303,16 +303,16 @@ fun <D : FunctionDescriptor> D.createCustomCopy(
private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction(isReleaseCoroutines: Boolean) = private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction(isReleaseCoroutines: Boolean) =
module.getContinuationOfTypeOrAny(returnType!!, if (this.needsExperimentalCoroutinesWrapper()) false else isReleaseCoroutines) module.getContinuationOfTypeOrAny(returnType!!, if (this.needsExperimentalCoroutinesWrapper()) false else isReleaseCoroutines)
fun ModuleDescriptor.getSuccessOrFailure(kotlinType: KotlinType) = fun ModuleDescriptor.getResult(kotlinType: KotlinType) =
module.resolveTopLevelClass( module.resolveTopLevelClass(
DescriptorUtils.SUCCESS_OR_FAILURE_FQ_NAME, DescriptorUtils.RESULT_FQ_NAME,
NoLookupLocation.FROM_BACKEND NoLookupLocation.FROM_BACKEND
)?.defaultType?.let { )?.defaultType?.let {
KotlinTypeFactory.simpleType( KotlinTypeFactory.simpleType(
it, it,
arguments = listOf(kotlinType.asTypeProjection()) arguments = listOf(kotlinType.asTypeProjection())
) )
} ?: ErrorUtils.createErrorType("For SuccessOrFailure") } ?: ErrorUtils.createErrorType("For Result")
private fun MethodNode.invokeNormalizeContinuation(languageVersionSettings: LanguageVersionSettings) { private fun MethodNode.invokeNormalizeContinuation(languageVersionSettings: LanguageVersionSettings) {
visitMethodInsn( visitMethodInsn(
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.codegen.state
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
import org.jetbrains.kotlin.resolve.DescriptorUtils.RESULT_FQ_NAME import org.jetbrains.kotlin.resolve.DescriptorUtils.RESULT_FQ_NAME
import org.jetbrains.kotlin.resolve.DescriptorUtils.SUCCESS_OR_FAILURE_FQ_NAME
import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
@@ -50,7 +49,7 @@ private fun KotlinType.isInlineClassThatRequiresMangling() =
isInlineClassType() && !isDontMangleClass(this.constructor.declarationDescriptor as ClassDescriptor) isInlineClassType() && !isDontMangleClass(this.constructor.declarationDescriptor as ClassDescriptor)
private fun isDontMangleClass(classDescriptor: ClassDescriptor) = private fun isDontMangleClass(classDescriptor: ClassDescriptor) =
classDescriptor.fqNameSafe == SUCCESS_OR_FAILURE_FQ_NAME || classDescriptor.fqNameSafe == RESULT_FQ_NAME classDescriptor.fqNameSafe == RESULT_FQ_NAME
private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean { private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean {
val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false
@@ -36,7 +36,7 @@ public class AsmTypes {
public static final Type MUTABLE_PROPERTY_REFERENCE1 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference1"); public static final Type MUTABLE_PROPERTY_REFERENCE1 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference1");
public static final Type MUTABLE_PROPERTY_REFERENCE2 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference2"); public static final Type MUTABLE_PROPERTY_REFERENCE2 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference2");
public static final Type SUCCESS_OR_FAILURE_FAILURE = Type.getObjectType("kotlin/SuccessOrFailure$Failure"); public static final Type RESULT_FAILURE = Type.getObjectType("kotlin/Result$Failure");
public static final Type[] PROPERTY_REFERENCE_IMPL = { public static final Type[] PROPERTY_REFERENCE_IMPL = {
Type.getObjectType("kotlin/jvm/internal/PropertyReference0Impl"), Type.getObjectType("kotlin/jvm/internal/PropertyReference0Impl"),
@@ -99,7 +99,7 @@ fun box(): String {
if (res != "first") { if (res != "first") {
return "" + res return "" + res
} }
continuation!!.resumeWith(SuccessOrFailure.success(Unit)) continuation!!.resumeWith(Result.success(Unit))
res = (continuation!! as BaseContinuationImpl).getSpilledVariableFieldMapping()!!.toMap()["I$0"] ?: "multipleLocalsInOneSlot fail 2" res = (continuation!! as BaseContinuationImpl).getSpilledVariableFieldMapping()!!.toMap()["I$0"] ?: "multipleLocalsInOneSlot fail 2"
if (res != "second") { if (res != "second") {
return "" + res return "" + res
@@ -10,30 +10,30 @@ fun builder(c: suspend () -> Unit) {
} }
@Suppress("UNSUPPORTED_FEATURE") @Suppress("UNSUPPORTED_FEATURE")
inline class SuccessOrFailure<T>(val a: Any?) { inline class Result<T>(val a: Any?) {
fun getOrThrow(): T = a as T fun getOrThrow(): T = a as T
} }
abstract class SuccessOrFailureReceiver<T> { abstract class ResultReceiver<T> {
abstract suspend fun receive(result: SuccessOrFailure<T>) abstract suspend fun receive(result: Result<T>)
} }
inline fun <T> SuccessOrFailureReceiver(crossinline f: (SuccessOrFailure<T>) -> Unit): SuccessOrFailureReceiver<T> = inline fun <T> ResultReceiver(crossinline f: (Result<T>) -> Unit): ResultReceiver<T> =
object : SuccessOrFailureReceiver<T>() { object : ResultReceiver<T>() {
override suspend fun receive(result: SuccessOrFailure<T>) { override suspend fun receive(result: Result<T>) {
f(result) f(result)
} }
} }
fun test() { fun test() {
var invoked = false var invoked = false
val receiver = SuccessOrFailureReceiver<String> { result -> val receiver = ResultReceiver<String> { result ->
val intResult = result.getOrThrow() val intResult = result.getOrThrow()
invoked = true invoked = true
} }
builder { builder {
receiver.receive(SuccessOrFailure("42")) receiver.receive(Result("42"))
} }
if (!invoked) { if (!invoked) {
throw RuntimeException("Fail") throw RuntimeException("Fail")
@@ -10,30 +10,30 @@ fun builder(c: suspend () -> Unit) {
} }
@Suppress("UNSUPPORTED_FEATURE") @Suppress("UNSUPPORTED_FEATURE")
inline class SuccessOrFailure<T>(val a: Any?) { inline class Result<T>(val a: Any?) {
fun getOrThrow(): T = a as T fun getOrThrow(): T = a as T
} }
abstract class SuccessOrFailureReceiver<T> { abstract class ResultReceiver<T> {
abstract suspend fun receive(result: SuccessOrFailure<T>) abstract suspend fun receive(result: Result<T>)
} }
fun <T> SuccessOrFailureReceiver(f: (SuccessOrFailure<T>) -> Unit): SuccessOrFailureReceiver<T> = fun <T> ResultReceiver(f: (Result<T>) -> Unit): ResultReceiver<T> =
object : SuccessOrFailureReceiver<T>() { object : ResultReceiver<T>() {
override suspend fun receive(result: SuccessOrFailure<T>) { override suspend fun receive(result: Result<T>) {
f(result) f(result)
} }
} }
fun test() { fun test() {
var invoked = false var invoked = false
val receiver = SuccessOrFailureReceiver<Int> { result -> val receiver = ResultReceiver<Int> { result ->
val intResult = result.getOrThrow() val intResult = result.getOrThrow()
invoked = true invoked = true
} }
builder { builder {
receiver.receive(SuccessOrFailure(42)) receiver.receive(Result(42))
} }
if (!invoked) { if (!invoked) {
throw RuntimeException("Fail") throw RuntimeException("Fail")
@@ -30,7 +30,7 @@ var proceed = {}
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> { cont -> suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> { cont ->
proceed = { proceed = {
cont.resumeWith(SuccessOrFailure.success(Unit)) cont.resumeWith(Result.success(Unit))
} }
COROUTINE_SUSPENDED COROUTINE_SUSPENDED
} }
@@ -32,7 +32,7 @@ var proceed = {}
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> { cont -> suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> { cont ->
proceed = { proceed = {
cont.resumeWith(SuccessOrFailure.success(Unit)) cont.resumeWith(Result.success(Unit))
} }
COROUTINE_SUSPENDED COROUTINE_SUSPENDED
} }
@@ -1,29 +1,29 @@
// !LANGUAGE: +InlineClasses // !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JVM_IR
inline class SuccessOrFailure<T>(val a: Any?) { inline class Result<T>(val a: Any?) {
fun getOrThrow(): T = a as T fun getOrThrow(): T = a as T
} }
abstract class SuccessOrFailureReceiver<T> { abstract class ResultReceiver<T> {
abstract fun receive(result: SuccessOrFailure<T>) abstract fun receive(result: Result<T>)
} }
fun <T> SuccessOrFailureReceiver(f: (SuccessOrFailure<T>) -> Unit): SuccessOrFailureReceiver<T> = fun <T> ResultReceiver(f: (Result<T>) -> Unit): ResultReceiver<T> =
object : SuccessOrFailureReceiver<T>() { object : ResultReceiver<T>() {
override fun receive(result: SuccessOrFailure<T>) { override fun receive(result: Result<T>) {
f(result) f(result)
} }
} }
fun test() { fun test() {
var invoked = false var invoked = false
val receiver = SuccessOrFailureReceiver<Int> { result -> val receiver = ResultReceiver<Int> { result ->
val intResult = result.getOrThrow() val intResult = result.getOrThrow()
invoked = true invoked = true
} }
receiver.receive(SuccessOrFailure(42)) receiver.receive(Result(42))
if (!invoked) { if (!invoked) {
throw RuntimeException("Fail") throw RuntimeException("Fail")
} }
@@ -1,29 +1,29 @@
// !LANGUAGE: +InlineClasses // !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JVM_IR
inline class SuccessOrFailure<T>(val a: Any?) { inline class Result<T>(val a: Any?) {
fun getOrThrow(): T = a as T fun getOrThrow(): T = a as T
} }
abstract class SuccessOrFailureReceiver<T> { abstract class ResultReceiver<T> {
abstract fun receive(result: SuccessOrFailure<T>) abstract fun receive(result: Result<T>)
} }
inline fun <T> SuccessOrFailureReceiver(crossinline f: (SuccessOrFailure<T>) -> Unit): SuccessOrFailureReceiver<T> = inline fun <T> ResultReceiver(crossinline f: (Result<T>) -> Unit): ResultReceiver<T> =
object : SuccessOrFailureReceiver<T>() { object : ResultReceiver<T>() {
override fun receive(result: SuccessOrFailure<T>) { override fun receive(result: Result<T>) {
f(result) f(result)
} }
} }
fun test() { fun test() {
var invoked = false var invoked = false
val receiver = SuccessOrFailureReceiver<String> { result -> val receiver = ResultReceiver<String> { result ->
val intResult = result.getOrThrow() val intResult = result.getOrThrow()
invoked = true invoked = true
} }
receiver.receive(SuccessOrFailure("42")) receiver.receive(Result("42"))
if (!invoked) { if (!invoked) {
throw RuntimeException("Fail") throw RuntimeException("Fail")
} }
+8 -8
View File
@@ -1,15 +1,15 @@
// !LANGUAGE: +InlineClasses // !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JVM_IR
inline class SuccessOrFailure<out T>(val value: Any?) { inline class Result<out T>(val value: Any?) {
val isFailure: Boolean get() = value is Failure val isFailure: Boolean get() = value is Failure
public companion object { public companion object {
public inline fun <T> success(value: T): SuccessOrFailure<T> = public inline fun <T> success(value: T): Result<T> =
SuccessOrFailure(value) Result(value)
public inline fun <T> failure(exception: Throwable): SuccessOrFailure<T> = public inline fun <T> failure(exception: Throwable): Result<T> =
SuccessOrFailure(Failure(exception)) Result(Failure(exception))
} }
class Failure ( class Failure (
@@ -17,11 +17,11 @@ inline class SuccessOrFailure<out T>(val value: Any?) {
) )
} }
inline fun <R> runCatching(block: () -> R): SuccessOrFailure<R> { inline fun <R> runCatching(block: () -> R): Result<R> {
return try { return try {
SuccessOrFailure.success(block()) Result.success(block())
} catch (e: Throwable) { } catch (e: Throwable) {
SuccessOrFailure.failure(e) Result.failure(e)
} }
} }
@@ -20,7 +20,7 @@ fun builder(c: suspend () -> Unit) {
override val context: CoroutineContext override val context: CoroutineContext
get() = EmptyCoroutineContext get() = EmptyCoroutineContext
override fun resumeWith(result: SuccessOrFailure<Unit>) { override fun resumeWith(result: Result<Unit>) {
result.getOrThrow() result.getOrThrow()
} }
}) })
@@ -18,7 +18,7 @@ fun builder(c: suspend () -> Unit) {
override val context: CoroutineContext override val context: CoroutineContext
get() = EmptyCoroutineContext get() = EmptyCoroutineContext
override fun resumeWith(result: SuccessOrFailure<Unit>) { override fun resumeWith(result: Result<Unit>) {
result.getOrThrow() result.getOrThrow()
} }
}) })
@@ -38,7 +38,7 @@ fun builder(c: suspend () -> Unit) {
override val context: CoroutineContext override val context: CoroutineContext
get() = EmptyCoroutineContext get() = EmptyCoroutineContext
override fun resumeWith(r: SuccessOrFailure<Unit>) { override fun resumeWith(r: Result<Unit>) {
r.getOrThrow() r.getOrThrow()
proceed = { proceed = {
result = "OK" result = "OK"
@@ -36,7 +36,7 @@ fun builder(c: suspend () -> Unit) {
override val context: CoroutineContext override val context: CoroutineContext
get() = EmptyCoroutineContext get() = EmptyCoroutineContext
override fun resumeWith(r: SuccessOrFailure<Unit>) { override fun resumeWith(r: Result<Unit>) {
r.getOrThrow() r.getOrThrow()
proceed = { proceed = {
result = "OK" result = "OK"
@@ -4,7 +4,7 @@
import kotlin.coroutines.* import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.* import kotlin.coroutines.intrinsics.*
suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x -> suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x ->
x.resumeWith(SuccessOrFailure.success("OK")) x.resumeWith(Result.success("OK"))
} }
suspend fun suspendThere(param: Int, param2: String, param3: Long): String { suspend fun suspendThere(param: Int, param2: String, param3: Long): String {
@@ -0,0 +1,37 @@
// WITH_COROUTINES
// FILE: test.kt
fun test() {
val result = Result.success("yes!")
val failure = Result.failure<String>(Exception())
if (result.isSuccess) println("success")
if (result.isFailure) println("failure")
println(result.getOrThrow())
println(failure.getOrNull())
println(failure.exceptionOrNull())
val other = Result.success("nope")
if (result == other) println("==")
if (result != other) println("!=")
if (result.equals(other)) println("equals")
if (!result.equals(other)) println("!equals")
println(result.hashCode())
println(result.toString())
println("$result")
val ans1 = runCatching { 42 }
println(ans1)
val ans2 = 42.runCatching { this }
println(ans2)
println(result.getOrElse { "oops" })
println(result.getOrDefault("oops"))
}
// @TestKt.class:
// 0 INVOKESTATIC Result.box-impl
// 0 INVOKESTATIC Result.unbox-impl
// 0 Result\$Failure
// 53 Result
@@ -1,36 +0,0 @@
// WITH_COROUTINES
// FILE: test.kt
fun testSoF() {
val sof = SuccessOrFailure.success("yes!")
val failure = SuccessOrFailure.failure<String>(Exception())
if (sof.isSuccess) println("success")
if (sof.isFailure) println("failure")
println(sof.getOrThrow())
println(failure.getOrNull())
println(failure.exceptionOrNull())
val other = SuccessOrFailure.success("nope")
if (sof == other) println("==")
if (sof != other) println("!=")
if (sof.equals(other)) println("equals")
if (!sof.equals(other)) println("!equals")
println(sof.hashCode())
println(sof.toString())
println("$sof")
val ans1 = runCatching { 42 }
println(ans1)
val ans2 = 42.runCatching { this }
println(ans2)
println(sof.getOrElse { "oops" })
println(sof.getOrDefault("oops"))
}
// @TestKt.class:
// 0 SuccessOrFailure\$Erased
// 0 SuccessOrFailure\-Erased
// 58 SuccessOrFailure
@@ -19,7 +19,7 @@ fun builder(x: suspend () -> Unit) {
x.startCoroutine(object : Continuation<Any?> { x.startCoroutine(object : Continuation<Any?> {
override val context: CoroutineContext = EmptyCoroutineContext override val context: CoroutineContext = EmptyCoroutineContext
override fun resumeWith(result: SuccessOrFailure<Any?>) { override fun resumeWith(result: Result<Any?>) {
result.getOrThrow() result.getOrThrow()
} }
}) })
@@ -17,7 +17,7 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String {
val emptyContinuationBody = val emptyContinuationBody =
if (isReleaseCoroutines) if (isReleaseCoroutines)
""" """
|override fun resumeWith(result: SuccessOrFailure<Any?>) { |override fun resumeWith(result: Result<Any?>) {
| result.getOrThrow() | result.getOrThrow()
|} |}
""".trimMargin() """.trimMargin()
@@ -30,7 +30,7 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String {
val handleResultContinuationBody = val handleResultContinuationBody =
if (isReleaseCoroutines) if (isReleaseCoroutines)
""" """
|override fun resumeWith(result: SuccessOrFailure<T>) { |override fun resumeWith(result: Result<T>) {
| x(result.getOrThrow()) | x(result.getOrThrow())
|} |}
""".trimMargin() """.trimMargin()
@@ -46,7 +46,7 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String {
val handleExceptionContinuationBody = val handleExceptionContinuationBody =
if (isReleaseCoroutines) if (isReleaseCoroutines)
""" """
|override fun resumeWith(result: SuccessOrFailure<Any?>) { |override fun resumeWith(result: Result<Any?>) {
| result.exceptionOrNull()?.let(x) | result.exceptionOrNull()?.let(x)
|} |}
""".trimMargin() """.trimMargin()
@@ -62,7 +62,7 @@ fun createTextForHelpers(isReleaseCoroutines: Boolean): String {
val continuationAdapterBody = val continuationAdapterBody =
if (isReleaseCoroutines) if (isReleaseCoroutines)
""" """
|override fun resumeWith(result: SuccessOrFailure<T>) { |override fun resumeWith(result: Result<T>) {
| if (result.isSuccess) { | if (result.isSuccess) {
| resume(result.getOrThrow()) | resume(result.getOrThrow())
| } else { | } else {
@@ -2168,16 +2168,16 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt"); runTest("compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt");
} }
@TestMetadata("resultApiDoesntUseBox.kt")
public void testResultApiDoesntUseBox() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt");
}
@TestMetadata("skipCallToUnderlyingValueOfInlineClass.kt") @TestMetadata("skipCallToUnderlyingValueOfInlineClass.kt")
public void testSkipCallToUnderlyingValueOfInlineClass() throws Exception { public void testSkipCallToUnderlyingValueOfInlineClass() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/skipCallToUnderlyingValueOfInlineClass.kt"); runTest("compiler/testData/codegen/bytecodeText/inlineClasses/skipCallToUnderlyingValueOfInlineClass.kt");
} }
@TestMetadata("successOrFailureApiDoesntUseErasedClass.kt")
public void testSuccessOrFailureApiDoesntUseErasedClass() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/successOrFailureApiDoesntUseErasedClass.kt");
}
@TestMetadata("toStringIsCalledByInlineClass.kt") @TestMetadata("toStringIsCalledByInlineClass.kt")
public void testToStringIsCalledByInlineClass() throws Exception { public void testToStringIsCalledByInlineClass() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/toStringIsCalledByInlineClass.kt"); runTest("compiler/testData/codegen/bytecodeText/inlineClasses/toStringIsCalledByInlineClass.kt");
@@ -44,7 +44,6 @@ public class DescriptorUtils {
COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("Continuation")); COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("Continuation"));
public static final FqName CONTINUATION_INTERFACE_FQ_NAME_RELEASE = public static final FqName CONTINUATION_INTERFACE_FQ_NAME_RELEASE =
COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("Continuation")); COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("Continuation"));
public static final FqName SUCCESS_OR_FAILURE_FQ_NAME = new FqName("kotlin.SuccessOrFailure");
public static final FqName RESULT_FQ_NAME = new FqName("kotlin.Result"); public static final FqName RESULT_FQ_NAME = new FqName("kotlin.Result");
// This JVM-specific class FQ name is declared here only because it's used in MainFunctionDetector which is in frontend // This JVM-specific class FQ name is declared here only because it's used in MainFunctionDetector which is in frontend
@@ -0,0 +1,8 @@
<html>
<body>
This inspection reports functions with <b>Result</b> result.
<b>Result</b> should never be used as return type.
Throw exception, or use nullable type, or use domain-specific result class to indicate failure.
</body>
</html>
@@ -1,8 +0,0 @@
<html>
<body>
This inspection reports functions with <b>SuccessOrFailure</b> result.
<b>SuccessOrFailure</b> should never be used as return type.
Throw exception, or use nullable type, or use domain-specific result class to indicate failure.
</body>
</html>
+2 -2
View File
@@ -3021,8 +3021,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
+2 -2
View File
@@ -3019,8 +3019,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
+2 -2
View File
@@ -3020,8 +3020,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
+2 -2
View File
@@ -3021,8 +3021,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
+2 -2
View File
@@ -3019,8 +3019,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
+2 -2
View File
@@ -3019,8 +3019,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
+2 -2
View File
@@ -3021,8 +3021,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
language="kotlin" language="kotlin"
/> />
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection" <localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection"
displayName="Function returning SuccessOrFailure" displayName="Function returning Result"
groupPath="Kotlin" groupPath="Kotlin"
groupName="Style issues" groupName="Style issues"
enabledByDefault="true" enabledByDefault="true"
@@ -35,7 +35,7 @@ class RedundantRunCatchingInspection : AbstractCallChainChecker() {
private val conversions = listOf( private val conversions = listOf(
Conversion( Conversion(
"kotlin.runCatching", "kotlin.runCatching",
"kotlin.SuccessOrFailure.getOrThrow", "kotlin.Result.getOrThrow",
"run" "run"
) )
) )
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
class ResultIsSuccessOrFailureInspection : AbstractKotlinInspection() { class ResultIsResultInspection : AbstractKotlinInspection() {
private fun MemberScope.hasCorrespondingNonCatchingFunction( private fun MemberScope.hasCorrespondingNonCatchingFunction(
nameWithoutCatching: String, nameWithoutCatching: String,
@@ -85,13 +85,13 @@ class ResultIsSuccessOrFailureInspection : AbstractKotlinInspection() {
if (name in ALLOWED_NAMES) return if (name in ALLOWED_NAMES) return
if (function is KtNamedFunction) { if (function is KtNamedFunction) {
val receiverTypeReference = function.receiverTypeReference val receiverTypeReference = function.receiverTypeReference
// Filter SuccessOrFailure extensions // Filter Result extensions
if (receiverTypeReference != null && SHORT_NAME in receiverTypeReference.text) return if (receiverTypeReference != null && SHORT_NAME in receiverTypeReference.text) return
} }
if (function is KtFunctionLiteral || returnTypeText == null) { if (function is KtFunctionLiteral || returnTypeText == null) {
// Heuristics to save performance // Heuristics to save performance
val text = function.bodyExpression?.text val text = function.bodyExpression?.text
// Check there is something creating SuccessOrFailure in function text // Check there is something creating Result in function text
if (text != null && ALLOWED_NAMES.none { it in text } && SHORT_NAME !in text && CATCHING !in text) return if (text != null && ALLOWED_NAMES.none { it in text } && SHORT_NAME !in text && CATCHING !in text) return
} }
@@ -192,7 +192,7 @@ class ResultIsSuccessOrFailureInspection : AbstractKotlinInspection() {
} }
companion object { companion object {
private const val SHORT_NAME = "SuccessOrFailure" private const val SHORT_NAME = "Result"
private const val FULL_NAME = "kotlin.$SHORT_NAME" private const val FULL_NAME = "kotlin.$SHORT_NAME"
+1 -1
View File
@@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> { open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
companion object : EmptyContinuation() companion object : EmptyContinuation()
override fun resumeWith(result: SuccessOrFailure<Any?>) { result.getOrThrow() } override fun resumeWith(result: Result<Any?>) { result.getOrThrow() }
} }
@@ -5,8 +5,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -14,8 +14,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -23,8 +23,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function 'incorrectCatching' returning 'SuccessOrFailure&lt;Double&gt;' without the corresponding function 'incorrect' returning 'Double'</description> <description>Function 'incorrectCatching' returning 'Result&lt;Double&gt;' without the corresponding function 'incorrect' returning 'Double'</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -32,8 +32,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function 'strangeCatching' returning 'SuccessOrFailure&lt;Boolean&gt;' without the corresponding function 'strange' returning 'Boolean'</description> <description>Function 'strangeCatching' returning 'Result&lt;Boolean&gt;' without the corresponding function 'strange' returning 'Boolean'</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -41,8 +41,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -50,8 +50,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -59,8 +59,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function 'classIncorrectCatching' returning 'SuccessOrFailure&lt;Double&gt;' without the corresponding function 'classIncorrect' returning 'Double'</description> <description>Function 'classIncorrectCatching' returning 'Result&lt;Double&gt;' without the corresponding function 'classIncorrect' returning 'Double'</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -68,8 +68,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -77,8 +77,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -86,8 +86,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function returning SuccessOrFailure with a name that does not end with Catching</description> <description>Function returning Result with a name that does not end with Catching</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -95,8 +95,8 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function 'calcComplexCatching' returning 'SuccessOrFailure&lt;Double&gt;' without the corresponding function 'calcComplex' returning 'Double'</description> <description>Function 'calcComplexCatching' returning 'Result&lt;Double&gt;' without the corresponding function 'calcComplex' returning 'Double'</description>
</problem> </problem>
<problem> <problem>
<file>test.kt</file> <file>test.kt</file>
@@ -104,7 +104,7 @@
<module>light_idea_test_case</module> <module>light_idea_test_case</module>
<package>&lt;default&gt;</package> <package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" /> <entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning SuccessOrFailure</problem_class> <problem_class severity="WEAK WARNING" attribute_key="INFO_ATTRIBUTES">Function returning Result</problem_class>
<description>Function 'extensionActCatching' returning 'SuccessOrFailure&lt;Int&gt;' without the corresponding function 'extensionAct' returning 'Int'</description> <description>Function 'extensionActCatching' returning 'Result&lt;Int&gt;' without the corresponding function 'extensionAct' returning 'Int'</description>
</problem> </problem>
</problems> </problems>
@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection // INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection
@@ -1,67 +1,67 @@
package kotlin package kotlin
// NO (constructor) // NO (constructor)
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
// YES // YES
fun getSuccess() = success() fun getSuccess() = success()
// YES // YES
fun getSuccessExplicit(): SuccessOrFailure<Int> = SuccessOrFailure(456) fun getSuccessExplicit(): Result<Int> = Result(456)
// NO (not catching 'correct' available) // NO (not catching 'correct' available)
fun correctCatching() = SuccessOrFailure(true) fun correctCatching() = Result(true)
// NO (not SuccessOrFailure) // NO (not Result)
fun correct() = true fun correct() = true
// YES // YES
fun incorrectCatching() = SuccessOrFailure(3.14) fun incorrectCatching() = Result(3.14)
// YES // YES
fun strangeCatching() = runCatching { false } fun strangeCatching() = runCatching { false }
// NO (not SuccessOrFailure) // NO (not Result)
fun strange() = 1 fun strange() = 1
class Container { class Container {
// YES // YES
fun classGetSuccess() = SuccessOrFailure("123") fun classGetSuccess() = Result("123")
// YES // YES
fun classGetSuccessExplicit(): SuccessOrFailure<Int> = SuccessOrFailure(456) fun classGetSuccessExplicit(): Result<Int> = Result(456)
// NO (not catching 'classCorrect' available) // NO (not catching 'classCorrect' available)
fun classCorrectCatching() = SuccessOrFailure(true) fun classCorrectCatching() = Result(true)
// NO (not SuccessOrFailure) // NO (not Result)
fun classCorrect() = true fun classCorrect() = true
// YES // YES
fun classIncorrectCatching() = SuccessOrFailure(3.14) fun classIncorrectCatching() = Result(3.14)
} }
fun test() { fun test() {
// YES // YES
fun localGetSuccess() = SuccessOrFailure("123") fun localGetSuccess() = Result("123")
// YES // YES
val anonymous = fun() = SuccessOrFailure(45) val anonymous = fun() = Result(45)
// YES // YES
val lambda = { SuccessOrFailure(true) } val lambda = { Result(true) }
// NO yet (we do not report local *catching functions) // NO yet (we do not report local *catching functions)
fun localCatching() = SuccessOrFailure(2.72) fun localCatching() = Result(2.72)
} }
// NO (stdlib) // NO (stdlib)
fun success() = SuccessOrFailure(true) fun success() = Result(true)
// NO (stdlib) // NO (stdlib)
fun failure() = SuccessOrFailure(false) fun failure() = Result(false)
// NO (stdlib) // NO (stdlib)
fun <T> runCatching(block: () -> T) = SuccessOrFailure(block()) fun <T> runCatching(block: () -> T) = Result(block())
// NO (stdlib) // NO (stdlib)
fun <T> SuccessOrFailure<T>.id() = this fun <T> Result<T>.id() = this
class ClassWithExtension() { class ClassWithExtension() {
// NO (not SuccessOrFailure) // NO (not Result)
fun calc() = 12345 fun calc() = 12345
// NO (not SuccessOrFailure) // NO (not Result)
fun calcComplex(arg1: Int, arg2: Double): Double = arg1 + arg2 fun calcComplex(arg1: Int, arg2: Double): Double = arg1 + arg2
// YES (different parameters) // YES (different parameters)
fun calcComplexCatching() = SuccessOrFailure(0.0) fun calcComplexCatching() = Result(0.0)
} }
// NO (extension to calc) // NO (extension to calc)
fun ClassWithExtension.calcCatching() = SuccessOrFailure(calc()) fun ClassWithExtension.calcCatching() = Result(calc())
// NO (not SuccessOrFailure) // NO (not Result)
fun Container.extensionAct() = 42 fun Container.extensionAct() = 42
// YES (different extension receiver) // YES (different extension receiver)
fun ClassWithExtension.extensionActCatching() = SuccessOrFailure(42) fun ClassWithExtension.extensionActCatching() = Result(42)
@@ -2,10 +2,10 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <T> runCatching(block: () -> T) = SuccessOrFailure(block()) fun <T> runCatching(block: () -> T) = Result(block())
fun correct(arg: Boolean) = runCatching<caret> { if (arg) throw AssertionError("") else 12 }.getOrThrow() fun correct(arg: Boolean) = runCatching<caret> { if (arg) throw AssertionError("") else 12 }.getOrThrow()
@@ -2,10 +2,10 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <T> runCatching(block: () -> T) = SuccessOrFailure(block()) fun <T> runCatching(block: () -> T) = Result(block())
fun correct(arg: Boolean) = run { if (arg) throw AssertionError("") else 12 } fun correct(arg: Boolean) = run { if (arg) throw AssertionError("") else 12 }
@@ -1 +1 @@
org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsSuccessOrFailureInspection org.jetbrains.kotlin.idea.inspections.coroutines.ResultIsResultInspection
@@ -1,10 +1,10 @@
// FIX: Unwrap 'SuccessOrFailure' return type (breaks use-sites!) // FIX: Unwrap 'Result' return type (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
abstract class Abstract { abstract class Abstract {
abstract fun <caret>foo(): SuccessOrFailure<Int> abstract fun <caret>foo(): Result<Int>
} }
@@ -1,7 +1,7 @@
// FIX: Unwrap 'SuccessOrFailure' return type (breaks use-sites!) // FIX: Unwrap 'Result' return type (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
@@ -1,9 +1,9 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test() { fun test() {
val x = <caret>fun() = SuccessOrFailure("123") val x = <caret>fun() = Result("123")
} }
@@ -1,9 +1,9 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test() { fun test() {
val x = fun() = SuccessOrFailure("123").getOrThrow() val x = fun() = Result("123").getOrThrow()
} }
@@ -3,28 +3,28 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <caret>incorrectBlock(arg: Boolean, arg2: Boolean?): SuccessOrFailure<Int> { fun <caret>incorrectBlock(arg: Boolean, arg2: Boolean?): Result<Int> {
if (arg) { if (arg) {
class Local { class Local {
fun foo(): SuccessOrFailure<String> { fun foo(): Result<String> {
return SuccessOrFailure("NO") return Result("NO")
} }
} }
return SuccessOrFailure(1) return Result(1)
} else { } else {
when (arg2) { when (arg2) {
true -> { true -> {
val x = fun(): SuccessOrFailure<Boolean> { val x = fun(): Result<Boolean> {
return SuccessOrFailure(false) return Result(false)
} }
if (x().getOrThrow()) { if (x().getOrThrow()) {
return SuccessOrFailure(2) return Result(2)
} else { } else {
return SuccessOrFailure(0) return Result(0)
} }
} }
else -> { else -> {
@@ -32,9 +32,9 @@ fun <caret>incorrectBlock(arg: Boolean, arg2: Boolean?): SuccessOrFailure<Int> {
listOf(1, 2, 3).forEach { listOf(1, 2, 3).forEach {
if (it == 2) return@forEach if (it == 2) return@forEach
} }
return SuccessOrFailure(3) return Result(3)
} }
return SuccessOrFailure(4) return Result(4)
} }
} }
} }
@@ -3,28 +3,28 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun incorrectBlock(arg: Boolean, arg2: Boolean?): Int { fun incorrectBlock(arg: Boolean, arg2: Boolean?): Int {
if (arg) { if (arg) {
class Local { class Local {
fun foo(): SuccessOrFailure<String> { fun foo(): Result<String> {
return SuccessOrFailure("NO") return Result("NO")
} }
} }
return SuccessOrFailure(1).getOrThrow() return Result(1).getOrThrow()
} else { } else {
when (arg2) { when (arg2) {
true -> { true -> {
val x = fun(): SuccessOrFailure<Boolean> { val x = fun(): Result<Boolean> {
return SuccessOrFailure(false) return Result(false)
} }
if (x().getOrThrow()) { if (x().getOrThrow()) {
return SuccessOrFailure(2).getOrThrow() return Result(2).getOrThrow()
} else { } else {
return SuccessOrFailure(0).getOrThrow() return Result(0).getOrThrow()
} }
} }
else -> { else -> {
@@ -32,9 +32,9 @@ fun incorrectBlock(arg: Boolean, arg2: Boolean?): Int {
listOf(1, 2, 3).forEach { listOf(1, 2, 3).forEach {
if (it == 2) return@forEach if (it == 2) return@forEach
} }
return SuccessOrFailure(3).getOrThrow() return Result(3).getOrThrow()
} }
return SuccessOrFailure(4).getOrThrow() return Result(4).getOrThrow()
} }
} }
} }
@@ -1,9 +1,9 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test() { fun test() {
val x = <caret>{ SuccessOrFailure(true) } val x = <caret>{ Result(true) }
} }
@@ -1,9 +1,9 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test() { fun test() {
val x = { SuccessOrFailure(true).getOrThrow() } val x = { Result(true).getOrThrow() }
} }
@@ -1,15 +1,15 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test(arg: Boolean) { fun test(arg: Boolean) {
val x = foo@<caret>{ val x = foo@<caret>{
if (!arg) { if (!arg) {
return@foo SuccessOrFailure(true) return@foo Result(true)
} else { } else {
SuccessOrFailure(false) Result(false)
} }
} }
} }
@@ -1,15 +1,15 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test(arg: Boolean) { fun test(arg: Boolean) {
val x = foo@{ val x = foo@{
(if (!arg) { (if (!arg) {
return@foo SuccessOrFailure(true).getOrThrow() return@foo Result(true).getOrThrow()
} else { } else {
SuccessOrFailure(false) Result(false)
}).getOrThrow() }).getOrThrow()
} }
} }
@@ -1,9 +1,9 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test() { fun test() {
val x = foo@<caret>{ return@foo SuccessOrFailure(true) } val x = foo@<caret>{ return@foo Result(true) }
} }
@@ -1,9 +1,9 @@
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun test() { fun test() {
val x = foo@<caret>{ return@foo SuccessOrFailure(true).getOrThrow() } val x = foo@<caret>{ return@foo Result(true).getOrThrow() }
} }
@@ -1,10 +1,10 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!) // FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
operator fun plus(other: SuccessOrFailure<T>) = other operator fun plus(other: Result<T>) = other
} }
fun <caret>incorrect() = SuccessOrFailure("123") + SuccessOrFailure("456") fun <caret>incorrect() = Result("123") + Result("456")
@@ -1,10 +1,10 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!) // FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
operator fun plus(other: SuccessOrFailure<T>) = other operator fun plus(other: Result<T>) = other
} }
fun incorrect() = (SuccessOrFailure("123") + SuccessOrFailure("456")).getOrThrow() fun incorrect() = (Result("123") + Result("456")).getOrThrow()
@@ -1,8 +1,8 @@
// FIX: Rename to 'incorrectCatching' // FIX: Rename to 'incorrectCatching'
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <caret>incorrect() = SuccessOrFailure("123") fun <caret>incorrect() = Result("123")
@@ -1,8 +1,8 @@
// FIX: Rename to 'incorrectCatching' // FIX: Rename to 'incorrectCatching'
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <caret>incorrectCatching() = SuccessOrFailure("123") fun <caret>incorrectCatching() = Result("123")
@@ -1,8 +1,8 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!) // FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <caret>incorrect() = SuccessOrFailure("123") fun <caret>incorrect() = Result("123")
@@ -1,8 +1,8 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!) // FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun incorrect() = SuccessOrFailure("123").getOrThrow() fun incorrect() = Result("123").getOrThrow()
@@ -1,21 +1,21 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!) // FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun <caret>incorrectBlock(arg: Boolean, arg2: Boolean?): SuccessOrFailure<Int> { fun <caret>incorrectBlock(arg: Boolean, arg2: Boolean?): Result<Int> {
if (arg) { if (arg) {
return SuccessOrFailure(1) return Result(1)
} else { } else {
when (arg2) { when (arg2) {
true -> return SuccessOrFailure(2) true -> return Result(2)
else -> { else -> {
if (arg2 == false) { if (arg2 == false) {
return SuccessOrFailure(3) return Result(3)
} }
return SuccessOrFailure(4) return Result(4)
} }
} }
} }
@@ -1,21 +1,21 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!) // FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin package kotlin
class SuccessOrFailure<T>(val value: T?) { class Result<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("") fun getOrThrow(): T = value ?: throw AssertionError("")
} }
fun incorrectBlock(arg: Boolean, arg2: Boolean?): Int { fun incorrectBlock(arg: Boolean, arg2: Boolean?): Int {
if (arg) { if (arg) {
return SuccessOrFailure(1).getOrThrow() return Result(1).getOrThrow()
} else { } else {
when (arg2) { when (arg2) {
true -> return SuccessOrFailure(2).getOrThrow() true -> return Result(2).getOrThrow()
else -> { else -> {
if (arg2 == false) { if (arg2 == false) {
return SuccessOrFailure(3).getOrThrow() return Result(3).getOrThrow()
} }
return SuccessOrFailure(4).getOrThrow() return Result(4).getOrThrow()
} }
} }
} }
@@ -19,7 +19,7 @@ fun build(x: suspend () -> Unit) {
x.startCoroutine(object : Continuation<Unit> { x.startCoroutine(object : Continuation<Unit> {
override val context = EmptyCoroutineContext override val context = EmptyCoroutineContext
override fun resumeWith(x: SuccessOrFailure<Unit>) { override fun resumeWith(x: Result<Unit>) {
complete = true complete = true
} }
}) })
@@ -12,7 +12,7 @@ suspend fun delay(): Unit = suspendCoroutine { c ->
fun build(c: suspend () -> Unit) { fun build(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit> { c.startCoroutine(object : Continuation<Unit> {
override fun resumeWith(x: SuccessOrFailure<Unit>) { override fun resumeWith(x: Result<Unit>) {
stopped = true stopped = true
} }
+1 -1
View File
@@ -21,7 +21,7 @@ fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit> { c.startCoroutine(object : Continuation<Unit> {
override val context = EmptyCoroutineContext override val context = EmptyCoroutineContext
override fun resumeWith(result: SuccessOrFailure<Unit>) {} override fun resumeWith(result: Result<Unit>) {}
}) })
} }
@@ -79,7 +79,7 @@ private class ExperimentalContinuationMigration<T>(val continuation: Continuatio
private class ContinuationMigration<T>(val continuation: ExperimentalContinuation<T>): Continuation<T> { private class ContinuationMigration<T>(val continuation: ExperimentalContinuation<T>): Continuation<T> {
override val context: CoroutineContext = continuation.context.toCoroutineContext() override val context: CoroutineContext = continuation.context.toCoroutineContext()
override fun resumeWith(result: SuccessOrFailure<T>) { override fun resumeWith(result: Result<T>) {
result result
.onSuccess { continuation.resume(it) } .onSuccess { continuation.resume(it) }
.onFailure { continuation.resumeWithException(it) } .onFailure { continuation.resumeWithException(it) }
@@ -17,5 +17,5 @@ internal expect class SafeContinuation<in T> : Continuation<T> {
internal fun getOrThrow(): Any? internal fun getOrThrow(): Any?
override val context: CoroutineContext override val context: CoroutineContext
override fun resumeWith(result: SuccessOrFailure<T>): Unit override fun resumeWith(result: Result<T>): Unit
} }
@@ -23,7 +23,7 @@ internal actual constructor(
private var result: Any? = initialResult private var result: Any? = initialResult
public actual override fun resumeWith(result: SuccessOrFailure<T>) { public actual override fun resumeWith(result: Result<T>) {
val cur = this.result val cur = this.result
when { when {
cur === UNDECIDED -> { cur === UNDECIDED -> {
@@ -46,7 +46,7 @@ internal actual constructor(
val result = this.result val result = this.result
return when { return when {
result === RESUMED -> COROUTINE_SUSPENDED // already called continuation, indicate COROUTINE_SUSPENDED upstream result === RESUMED -> COROUTINE_SUSPENDED // already called continuation, indicate COROUTINE_SUSPENDED upstream
result is SuccessOrFailure.Failure -> throw result.exception result is Result.Failure -> throw result.exception
else -> result // either COROUTINE_SUSPENDED or data else -> result // either COROUTINE_SUSPENDED or data
} }
} }
@@ -25,7 +25,7 @@ internal abstract class CoroutineImpl(private val resultContinuation: Continuati
?: (context[ContinuationInterceptor]?.interceptContinuation(this) ?: this) ?: (context[ContinuationInterceptor]?.interceptContinuation(this) ?: this)
.also { intercepted_ = it } .also { intercepted_ = it }
override fun resumeWith(result: SuccessOrFailure<Any?>) { override fun resumeWith(result: Result<Any?>) {
var current = this var current = this
var currentResult: Any? = result.getOrNull() var currentResult: Any? = result.getOrNull()
var currentException: Throwable? = result.exceptionOrNull() var currentException: Throwable? = result.exceptionOrNull()
@@ -84,7 +84,7 @@ internal object CompletedContinuation : Continuation<Any?> {
override val context: CoroutineContext override val context: CoroutineContext
get() = error("This continuation is already complete") get() = error("This continuation is already complete")
override fun resumeWith(result: SuccessOrFailure<Any?>) { override fun resumeWith(result: Result<Any?>) {
error("This continuation is already complete") error("This continuation is already complete")
} }
@@ -34,7 +34,7 @@ internal actual constructor(
) )
} }
public actual override fun resumeWith(result: SuccessOrFailure<T>) { public actual override fun resumeWith(result: Result<T>) {
while (true) { // lock-free loop while (true) { // lock-free loop
val cur = this.result // atomic read val cur = this.result // atomic read
when { when {
@@ -57,7 +57,7 @@ internal actual constructor(
} }
return when { return when {
result === RESUMED -> COROUTINE_SUSPENDED // already called continuation, indicate COROUTINE_SUSPENDED upstream result === RESUMED -> COROUTINE_SUSPENDED // already called continuation, indicate COROUTINE_SUSPENDED upstream
result is SuccessOrFailure.Failure -> throw result.exception result is Result.Failure -> throw result.exception
else -> result // either COROUTINE_SUSPENDED or data else -> result // either COROUTINE_SUSPENDED or data
} }
} }
@@ -162,7 +162,7 @@ private inline fun <T> createCoroutineFromSuspendFunction(
object : RestrictedContinuationImpl(completion as Continuation<Any?>) { object : RestrictedContinuationImpl(completion as Continuation<Any?>) {
private var label = 0 private var label = 0
override fun invokeSuspend(result: SuccessOrFailure<Any?>): Any? = override fun invokeSuspend(result: Result<Any?>): Any? =
when (label) { when (label) {
0 -> { 0 -> {
label = 1 label = 1
@@ -180,7 +180,7 @@ private inline fun <T> createCoroutineFromSuspendFunction(
object : ContinuationImpl(completion as Continuation<Any?>, context) { object : ContinuationImpl(completion as Continuation<Any?>, context) {
private var label = 0 private var label = 0
override fun invokeSuspend(result: SuccessOrFailure<Any?>): Any? = override fun invokeSuspend(result: Result<Any?>): Any? =
when (label) { when (label) {
0 -> { 0 -> {
label = 1 label = 1
@@ -18,7 +18,7 @@ internal abstract class BaseContinuationImpl(
public val completion: Continuation<Any?>? public val completion: Continuation<Any?>?
) : Continuation<Any?>, CoroutineStackFrame, Serializable { ) : Continuation<Any?>, CoroutineStackFrame, Serializable {
// This implementation is final. This fact is used to unroll resumeWith recursion. // This implementation is final. This fact is used to unroll resumeWith recursion.
public final override fun resumeWith(result: SuccessOrFailure<Any?>) { public final override fun resumeWith(result: Result<Any?>) {
// Invoke "resume" debug probe only once, even if previous frames are "resumed" in the loop below, too // Invoke "resume" debug probe only once, even if previous frames are "resumed" in the loop below, too
probeCoroutineResumed(this) probeCoroutineResumed(this)
// This loop unrolls recursion in current.resumeWith(param) to make saner and shorter stack traces on resume // This loop unrolls recursion in current.resumeWith(param) to make saner and shorter stack traces on resume
@@ -27,13 +27,13 @@ internal abstract class BaseContinuationImpl(
while (true) { while (true) {
with(current) { with(current) {
val completion = completion!! // fail fast when trying to resume continuation without completion val completion = completion!! // fail fast when trying to resume continuation without completion
val outcome: SuccessOrFailure<Any?> = val outcome: Result<Any?> =
try { try {
val outcome = invokeSuspend(param) val outcome = invokeSuspend(param)
if (outcome === COROUTINE_SUSPENDED) return if (outcome === COROUTINE_SUSPENDED) return
SuccessOrFailure.success(outcome) Result.success(outcome)
} catch (exception: Throwable) { } catch (exception: Throwable) {
SuccessOrFailure.failure(exception) Result.failure(exception)
} }
releaseIntercepted() // this state machine instance is terminating releaseIntercepted() // this state machine instance is terminating
if (completion is BaseContinuationImpl) { if (completion is BaseContinuationImpl) {
@@ -49,7 +49,7 @@ internal abstract class BaseContinuationImpl(
} }
} }
protected abstract fun invokeSuspend(result: SuccessOrFailure<Any?>): Any? protected abstract fun invokeSuspend(result: Result<Any?>): Any?
protected open fun releaseIntercepted() { protected open fun releaseIntercepted() {
// does nothing here, overridden in ContinuationImpl // does nothing here, overridden in ContinuationImpl
@@ -124,7 +124,7 @@ internal object CompletedContinuation : Continuation<Any?> {
override val context: CoroutineContext override val context: CoroutineContext
get() = error("This continuation is already complete") get() = error("This continuation is already complete")
override fun resumeWith(result: SuccessOrFailure<Any?>) { override fun resumeWith(result: Result<Any?>) {
error("This continuation is already complete") error("This continuation is already complete")
} }
@@ -24,9 +24,9 @@ private class RunSuspend : Continuation<Unit> {
override val context: CoroutineContext override val context: CoroutineContext
get() = EmptyCoroutineContext get() = EmptyCoroutineContext
var result: SuccessOrFailure<Unit>? = null var result: Result<Unit>? = null
override fun resumeWith(result: SuccessOrFailure<Unit>) = synchronized(this) { override fun resumeWith(result: Result<Unit>) = synchronized(this) {
this.result = result this.result = result
(this as Object).notifyAll() (this as Object).notifyAll()
} }
@@ -33,7 +33,7 @@ private class MyContinuation : BaseContinuationImpl(null) {
var label = 0 var label = 0
override fun invokeSuspend(result: SuccessOrFailure<Any?>): Any? = null override fun invokeSuspend(result: Result<Any?>): Any? = null
} }
class DebugMetadataTest { class DebugMetadataTest {
@@ -7,7 +7,7 @@ package test.kotlin
import kotlin.test.* import kotlin.test.*
class SuccessOrFailureTest { class ResultTest {
@Test @Test
fun testRunCatchingSuccess() { fun testRunCatchingSuccess() {
val ok = runCatching { "OK" } val ok = runCatching { "OK" }
@@ -22,17 +22,17 @@ class SuccessOrFailureTest {
@Test @Test
fun testConstructedSuccess() { fun testConstructedSuccess() {
val ok = SuccessOrFailure.success("OK") val ok = Result.success("OK")
checkSuccess(ok, "OK", true) checkSuccess(ok, "OK", true)
} }
@Test @Test
fun testConstructedFailure() { fun testConstructedFailure() {
val fail = SuccessOrFailure.failure<Unit>(IllegalStateException("F")) val fail = Result.failure<Unit>(IllegalStateException("F"))
checkFailure(fail, "F", true) checkFailure(fail, "F", true)
} }
private fun <T> checkSuccess(ok: SuccessOrFailure<T>, v: T, topLevel: Boolean = false) { private fun <T> checkSuccess(ok: Result<T>, v: T, topLevel: Boolean = false) {
assertTrue(ok.isSuccess) assertTrue(ok.isSuccess)
assertFalse(ok.isFailure) assertFalse(ok.isFailure)
assertEquals(v, ok.getOrThrow()) assertEquals(v, ok.getOrThrow())
@@ -44,7 +44,7 @@ class SuccessOrFailureTest {
assertEquals("V:$v", ok.fold({ "V:$it" }, { "EX:$it" })) assertEquals("V:$v", ok.fold({ "V:$it" }, { "EX:$it" }))
assertEquals(null, ok.exceptionOrNull()) assertEquals(null, ok.exceptionOrNull())
assertEquals(null, ok.fold(onSuccess = { null }, onFailure = { it })) assertEquals(null, ok.fold(onSuccess = { null }, onFailure = { it }))
assertEquals(v.toString(), ok.toString()) assertEquals("Success($v)", ok.toString())
assertEquals(ok, ok) assertEquals(ok, ok)
if (topLevel) { if (topLevel) {
checkSuccess(ok.map { 42 }, 42) checkSuccess(ok.map { 42 }, 42)
@@ -62,7 +62,7 @@ class SuccessOrFailureTest {
assertEquals(0, fCnt) assertEquals(0, fCnt)
} }
private fun <T> checkFailure(fail: SuccessOrFailure<T>, msg: String, topLevel: Boolean = false) { private fun <T> checkFailure(fail: Result<T>, msg: String, topLevel: Boolean = false) {
assertFalse(fail.isSuccess) assertFalse(fail.isSuccess)
assertTrue(fail.isFailure) assertTrue(fail.isFailure)
assertFails { fail.getOrThrow() } assertFails { fail.getOrThrow() }
@@ -41,7 +41,7 @@ class TestDispatcher(
inner class DispatchedContinuation<T>(val delegate: Continuation<T>) : Continuation<T> { inner class DispatchedContinuation<T>(val delegate: Continuation<T>) : Continuation<T> {
override val context: CoroutineContext = delegate.context override val context: CoroutineContext = delegate.context
override fun resumeWith(result: SuccessOrFailure<T>) { override fun resumeWith(result: Result<T>) {
executor.execute { executor.execute {
delegate.resumeWith(result) delegate.resumeWith(result)
} }
@@ -0,0 +1,328 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("UNCHECKED_CAST", "RedundantVisibilityModifier")
package kotlin
import kotlin.contracts.*
import kotlin.internal.InlineOnly
import kotlin.jvm.JvmField
/**
* A discriminated union that encapsulates successful outcome with a value of type [T]
* or a failure with an arbitrary [Throwable] exception.
*/
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
public inline class Result<out T> @PublishedApi internal constructor(
@PublishedApi
internal val value: Any?
) : Serializable {
// discovery
/**
* Returns `true` if this instance represents successful outcome.
* In this case [isFailure] returns `false`.
*/
public val isSuccess: Boolean get() = value !is Failure
/**
* Returns `true` if this instance represents failed outcome.
* In this case [isSuccess] returns `false`.
*/
public val isFailure: Boolean get() = value is Failure
// value & exception retrieval
/**
* Returns the encapsulated value if this instance represents [success][Result.isSuccess] or `null`
* if it is [failure][Result.isFailure].
*
* This function is shorthand for `getOrElse { null }` (see [getOrElse]) or
* `fold(onSuccess = { it }, onFailure = { null })` (see [fold]).
*/
public fun getOrNull(): T? =
when (value) {
is Failure -> null
else -> value as T
}
/**
* Returns the encapsulated exception if this instance represents [failure][isFailure] or `null`
* if it is [success][isSuccess].
*
* This function is shorthand for `fold(onSuccess = { null }, onFailure = { it })` (see [fold]).
*/
public fun exceptionOrNull(): Throwable? =
when (value) {
is Failure -> value.exception
else -> null
}
/**
* Returns a string `Success(v)` if this instance represents [success][Result.isSuccess]
* where `v` is a string representation of the value or a string `Failure(x)` if
* it is [failure][isFailure] where `x` is a string representation of the exception.
*/
public override fun toString(): String =
when (value) {
is Failure -> value.toString() // "Failure($exception)"
else -> "Success($value)"
}
// companion with constructors
/**
* Companion object for [Result] class that contains its constructor functions
* [success] and [failure].
*/
public companion object {
/**
* Returns an instance that encapsulates the given [value] as successful value.
*/
@InlineOnly public inline fun <T> success(value: T): Result<T> =
Result(value)
/**
* Returns an instance that encapsulates the given [exception] as failure.
*/
@InlineOnly public inline fun <T> failure(exception: Throwable): Result<T> =
Result(createFailure(exception))
}
internal class Failure(
@JvmField
val exception: Throwable
) : Serializable {
override fun equals(other: Any?): Boolean = other is Failure && exception == other.exception
override fun hashCode(): Int = exception.hashCode()
override fun toString(): String = "Failure($exception)"
}
}
/**
* Creates an instance of internal marker [Result.Failure] class to
* make sure that this class is not exposed in ABI.
*/
@PublishedApi
internal fun createFailure(exception: Throwable): Any =
Result.Failure(exception)
/**
* Throws exception if the result is failure. This internal function minimizes
* inlined bytecode for [getOrThrow] and makes sure that in the future we can
* add some exception-augmenting logic here (if needed).
*/
@PublishedApi
internal fun Result<*>.throwOnFailure() {
if (value is Result.Failure) throw value.exception
}
/**
* Calls the specified function [block] and returns its encapsulated result if invocation was successful,
* catching and encapsulating any thrown exception as a failure.
*/
@InlineOnly
public inline fun <R> runCatching(block: () -> R): Result<R> {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return try {
Result.success(block())
} catch (e: Throwable) {
Result.failure(e)
}
}
/**
* Calls the specified function [block] with `this` value as its receiver and returns its encapsulated result
* if invocation was successful, catching and encapsulating any thrown exception as a failure.
*/
@InlineOnly
public inline fun <T, R> T.runCatching(block: T.() -> R): Result<R> {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return try {
Result.success(block())
} catch (e: Throwable) {
Result.failure(e)
}
}
// -- extensions ---
/**
* Returns the encapsulated value if this instance represents [success][Result.isSuccess] or throws the encapsulated exception
* if it is [failure][Result.isFailure].
*
* This function is shorthand for `getOrElse { throw it }` (see [getOrElse]).
*/
@InlineOnly
public inline fun <T> Result<T>.getOrThrow(): T {
throwOnFailure()
return value as T
}
/**
* Returns the encapsulated value if this instance represents [success][Result.isSuccess] or the
* result of [onFailure] function for encapsulated exception if it is [failure][Result.isFailure].
*
* Note, that an exception thrown by [onFailure] function is rethrown by this function.
*
* This function is shorthand for `fold(onSuccess = { it }, onFailure = onFailure)` (see [fold]).
*/
@InlineOnly
public inline fun <R, T : R> Result<T>.getOrElse(onFailure: (exception: Throwable) -> R): R {
contract {
callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE)
}
return when(val exception = exceptionOrNull()) {
null -> value as T
else -> onFailure(exception)
}
}
/**
* Returns the encapsulated value if this instance represents [success][Result.isSuccess] or the
* [defaultValue] if it is [failure][Result.isFailure].
*
* This function is shorthand for `getOrElse { defaultValue }` (see [getOrElse]).
*/
@InlineOnly
public inline fun <R, T : R> Result<T>.getOrDefault(defaultValue: R): R {
if (isFailure) return defaultValue
return value as T
}
/**
* Returns the the result of [onSuccess] for encapsulated value if this instance represents [success][Result.isSuccess]
* or the result of [onFailure] function for encapsulated exception if it is [failure][Result.isFailure].
*
* Note, that an exception thrown by [onSuccess] or by [onFailure] function is rethrown by this function.
*/
@InlineOnly
public inline fun <R, T> Result<T>.fold(
onSuccess: (value: T) -> R,
onFailure: (exception: Throwable) -> R
): R {
contract {
callsInPlace(onSuccess, InvocationKind.AT_MOST_ONCE)
callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE)
}
return when(val exception = exceptionOrNull()) {
null -> onSuccess(value as T)
else -> onFailure(exception)
}
}
// transformation
/**
* Returns the encapsulated result of the given [transform] function applied to encapsulated value
* if this instance represents [success][Result.isSuccess] or the
* original encapsulated exception if it is [failure][Result.isFailure].
*
* Note, that an exception thrown by [transform] function is rethrown by this function.
* See [mapCatching] for an alternative that encapsulates exceptions.
*/
@InlineOnly
public inline fun <R, T> Result<T>.map(transform: (value: T) -> R): Result<R> {
contract {
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
}
return when(val exception = exceptionOrNull()) {
null -> Result.success(transform(value as T))
else -> Result(value)
}
}
/**
* Returns the encapsulated result of the given [transform] function applied to encapsulated value
* if this instance represents [success][Result.isSuccess] or the
* original encapsulated exception if it is [failure][Result.isFailure].
*
* Any exception thrown by [transform] function is caught, encapsulated as a failure and returned by this function.
* See [map] for an alternative that rethrows exceptions.
*/
@InlineOnly
public inline fun <R, T> Result<T>.mapCatching(transform: (value: T) -> R): Result<R> {
contract {
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
}
return when(val exception = exceptionOrNull()) {
null -> runCatching { transform(value as T) }
else -> Result(value)
}
}
/**
* Returns the encapsulated result of the given [transform] function applied to encapsulated exception
* if this instance represents [failure][Result.isFailure] or the
* original encapsulated value if it is [success][Result.isSuccess].
*
* Note, that an exception thrown by [transform] function is rethrown by this function.
* See [recoverCatching] for an alternative that encapsulates exceptions.
*/
@InlineOnly
public inline fun <R, T: R> Result<T>.recover(transform: (exception: Throwable) -> R): Result<R> {
contract {
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
}
return when(val exception = exceptionOrNull()) {
null -> this
else -> Result.success(transform(exception))
}
}
/**
* Returns the encapsulated result of the given [transform] function applied to encapsulated exception
* if this instance represents [failure][Result.isFailure] or the
* original encapsulated value if it is [success][Result.isSuccess].
*
* Any exception thrown by [transform] function is caught, encapsulated as a failure and returned by this function.
* See [recover] for an alternative that rethrows exceptions.
*/
@InlineOnly
public inline fun <R, T: R> Result<T>.recoverCatching(transform: (exception: Throwable) -> R): Result<R> {
contract {
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
}
val value = value // workaround for inline classes BE bug
return when(val exception = exceptionOrNull()) {
null -> this
else -> runCatching { transform(exception) }
}
}
// "peek" onto value/exception and pipe
/**
* Performs the given [action] on encapsulated value if this instance represents [success][Result.isSuccess].
* Returns the original `Result` unchanged.
*/
@InlineOnly
public inline fun <T> Result<T>.onFailure(action: (exception: Throwable) -> Unit): Result<T> {
contract {
callsInPlace(action, InvocationKind.AT_MOST_ONCE)
}
exceptionOrNull()?.let { action(it) }
return this
}
/**
* Performs the given [action] on encapsulated exception if this instance represents [failure][Result.isFailure].
* Returns the original `Result` unchanged.
*/
@InlineOnly
public inline fun <T> Result<T>.onSuccess(action: (value: T) -> Unit): Result<T> {
contract {
callsInPlace(action, InvocationKind.AT_MOST_ONCE)
}
if (isSuccess) action(value as T)
return this
}
// -------------------
@@ -7,6 +7,7 @@ package kotlin.coroutines
import kotlin.coroutines.intrinsics.* import kotlin.coroutines.intrinsics.*
import kotlin.internal.InlineOnly import kotlin.internal.InlineOnly
import kotlin.jvm.JvmName
/** /**
* Interface representing a continuation after a suspension point that returns value of type `T`. * Interface representing a continuation after a suspension point that returns value of type `T`.
@@ -23,7 +24,7 @@ public interface Continuation<in T> {
* Resumes the execution of the corresponding coroutine passing successful or failed [result] as the * Resumes the execution of the corresponding coroutine passing successful or failed [result] as the
* return value of the last suspension point. * return value of the last suspension point.
*/ */
public fun resumeWith(result: SuccessOrFailure<T>) public fun resumeWith(result: Result<T>)
} }
/** /**
@@ -41,7 +42,7 @@ public annotation class RestrictsSuspension
*/ */
@SinceKotlin("1.3") @SinceKotlin("1.3")
@InlineOnly public inline fun <T> Continuation<T>.resume(value: T): Unit = @InlineOnly public inline fun <T> Continuation<T>.resume(value: T): Unit =
resumeWith(SuccessOrFailure.success(value)) resumeWith(Result.success(value))
/** /**
* Resumes the execution of the corresponding coroutine so that the [exception] is re-thrown right after the * Resumes the execution of the corresponding coroutine so that the [exception] is re-thrown right after the
@@ -49,7 +50,7 @@ public annotation class RestrictsSuspension
*/ */
@SinceKotlin("1.3") @SinceKotlin("1.3")
@InlineOnly public inline fun <T> Continuation<T>.resumeWithException(exception: Throwable): Unit = @InlineOnly public inline fun <T> Continuation<T>.resumeWithException(exception: Throwable): Unit =
resumeWith(SuccessOrFailure.failure(exception)) resumeWith(Result.failure(exception))
/** /**
@@ -58,13 +59,13 @@ public annotation class RestrictsSuspension
@SinceKotlin("1.3") @SinceKotlin("1.3")
@InlineOnly public inline fun <T> Continuation( @InlineOnly public inline fun <T> Continuation(
context: CoroutineContext, context: CoroutineContext,
crossinline resumeWith: (SuccessOrFailure<T>) -> Unit crossinline resumeWith: (Result<T>) -> Unit
): Continuation<T> = ): Continuation<T> =
object : Continuation<T> { object : Continuation<T> {
override val context: CoroutineContext override val context: CoroutineContext
get() = context get() = context
override fun resumeWith(result: SuccessOrFailure<T>) = override fun resumeWith(result: Result<T>) =
resumeWith(result) resumeWith(result)
} }
@@ -172,7 +172,7 @@ private class SequenceBuilderIterator<T> : SequenceBuilder<T>(), Iterator<T>, Co
} }
// Completion continuation implementation // Completion continuation implementation
override fun resumeWith(result: SuccessOrFailure<Unit>) { override fun resumeWith(result: Result<Unit>) {
result.getOrThrow() // just rethrow exception if it is there result.getOrThrow() // just rethrow exception if it is there
state = State_Done state = State_Done
} }
@@ -45,7 +45,7 @@ class CoroutinesReferenceValuesTest {
bad.startCoroutine(object : Continuation<BadClass> { bad.startCoroutine(object : Continuation<BadClass> {
override val context: CoroutineContext = EmptyCoroutineContext override val context: CoroutineContext = EmptyCoroutineContext
override fun resumeWith(result_: SuccessOrFailure<BadClass>) { override fun resumeWith(result_: Result<BadClass>) {
assertTrue(result == null) assertTrue(result == null)
result = result_.getOrThrow() result = result_.getOrThrow()
} }
@@ -141,27 +141,53 @@ public abstract interface annotation class kotlin/ReplaceWith : java/lang/annota
public abstract fun imports ()[Ljava/lang/String; public abstract fun imports ()[Ljava/lang/String;
} }
public final class kotlin/Result : java/io/Serializable {
public static final field Companion Lkotlin/Result$Companion;
public static final synthetic fun box-impl (Ljava/lang/Object;)Lkotlin/Result;
public static fun constructor-impl (Ljava/lang/Object;)Ljava/lang/Object;
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (Ljava/lang/Object;Ljava/lang/Object;)Z
public static final fun equals-impl0 (Ljava/lang/Object;Ljava/lang/Object;)Z
public static final fun exceptionOrNull-impl (Ljava/lang/Object;)Ljava/lang/Throwable;
public static final fun getOrNull-impl (Ljava/lang/Object;)Ljava/lang/Object;
public fun hashCode ()I
public static fun hashCode-impl (Ljava/lang/Object;)I
public static final fun isFailure-impl (Ljava/lang/Object;)Z
public static final fun isSuccess-impl (Ljava/lang/Object;)Z
public fun toString ()Ljava/lang/String;
public static fun toString-impl (Ljava/lang/Object;)Ljava/lang/String;
public final synthetic fun unbox-impl ()Ljava/lang/Object;
}
public final class kotlin/Result$Companion {
}
public final class kotlin/ResultKt {
public static final fun createFailure (Ljava/lang/Throwable;)Ljava/lang/Object;
public static final fun throwOnFailure (Ljava/lang/Object;)V
}
public abstract interface annotation class kotlin/SinceKotlin : java/lang/annotation/Annotation { public abstract interface annotation class kotlin/SinceKotlin : java/lang/annotation/Annotation {
public abstract fun version ()Ljava/lang/String; public abstract fun version ()Ljava/lang/String;
} }
public final class kotlin/SuccessOrFailure : java/io/Serializable { public final class kotlin/SuccessOrFailure : java/io/Serializable {
public static final field Companion Lkotlin/SuccessOrFailure$Companion; public static final field Companion Lkotlin/SuccessOrFailure$Companion;
public synthetic fun <init> (Ljava/lang/Object;)V public static final synthetic fun box-impl (Ljava/lang/Object;)Lkotlin/SuccessOrFailure;
public static final fun box (Ljava/lang/Object;)Lkotlin/SuccessOrFailure; public static fun constructor-impl (Ljava/lang/Object;)Ljava/lang/Object;
public static fun constructor (Ljava/lang/Object;)Ljava/lang/Object;
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals (Ljava/lang/Object;Ljava/lang/Object;)Z public static fun equals-impl (Ljava/lang/Object;Ljava/lang/Object;)Z
public static final fun exceptionOrNull (Ljava/lang/Object;)Ljava/lang/Throwable; public static final fun equals-impl0 (Ljava/lang/Object;Ljava/lang/Object;)Z
public static final fun getOrNull (Ljava/lang/Object;)Ljava/lang/Object; public static final fun exceptionOrNull-impl (Ljava/lang/Object;)Ljava/lang/Throwable;
public static final fun getOrThrow (Ljava/lang/Object;)Ljava/lang/Object; public static final fun getOrNull-impl (Ljava/lang/Object;)Ljava/lang/Object;
public static final fun getOrThrow-impl (Ljava/lang/Object;)Ljava/lang/Object;
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode (Ljava/lang/Object;)I public static fun hashCode-impl (Ljava/lang/Object;)I
public static final fun isFailure (Ljava/lang/Object;)Z public static final fun isFailure-impl (Ljava/lang/Object;)Z
public static final fun isSuccess (Ljava/lang/Object;)Z public static final fun isSuccess-impl (Ljava/lang/Object;)Z
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString (Ljava/lang/Object;)Ljava/lang/String; public static fun toString-impl (Ljava/lang/Object;)Ljava/lang/String;
public final fun unbox ()Ljava/lang/Object; public final synthetic fun unbox-impl ()Ljava/lang/Object;
} }
public final class kotlin/SuccessOrFailure$Companion { public final class kotlin/SuccessOrFailure$Companion {
@@ -175,10 +201,6 @@ public final class kotlin/SuccessOrFailure$Failure : java/io/Serializable {
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
public final class kotlin/SuccessOrFailureKt {
public static final fun getOrDefault (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
}
public abstract interface annotation class kotlin/Suppress : java/lang/annotation/Annotation { public abstract interface annotation class kotlin/Suppress : java/lang/annotation/Annotation {
public abstract fun names ()[Ljava/lang/String; public abstract fun names ()[Ljava/lang/String;
} }
@@ -215,97 +237,98 @@ public final class kotlin/UByte : java/lang/Comparable {
public static final field MIN_VALUE B public static final field MIN_VALUE B
public static final field SIZE_BITS I public static final field SIZE_BITS I
public static final field SIZE_BYTES I public static final field SIZE_BYTES I
public static final fun and-d0xlk1d1 (BB)B public static final fun and-7apg3OU (BB)B
public static final fun box (B)Lkotlin/UByte; public static final synthetic fun box-impl (B)Lkotlin/UByte;
public synthetic fun compareTo (Ljava/lang/Object;)I public synthetic fun compareTo (Ljava/lang/Object;)I
public static final fun compareTo-4n0qz0s4 (BJ)I public fun compareTo-7apg3OU (B)I
public static final fun compareTo-4wtlwgkb (BI)I public static fun compareTo-7apg3OU (BB)I
public static final fun compareTo-av578izg (BS)I public static final fun compareTo-VKZWuLQ (BJ)I
public fun compareTo-d0xlk1d1 (B)I public static final fun compareTo-WZ4Q5Ns (BI)I
public static fun compareTo-d0xlk1d1 (BB)I public static final fun compareTo-xj2QHRw (BS)I
public static fun constructor (B)B public static fun constructor-impl (B)B
public static final fun dec (B)B public static final fun dec-impl (B)B
public static final fun div-4n0qz0s4 (BJ)J public static final fun div-7apg3OU (BB)I
public static final fun div-4wtlwgkb (BI)I public static final fun div-VKZWuLQ (BJ)J
public static final fun div-av578izg (BS)I public static final fun div-WZ4Q5Ns (BI)I
public static final fun div-d0xlk1d1 (BB)I public static final fun div-xj2QHRw (BS)I
public static fun equals (BLjava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (BLjava/lang/Object;)Z
public static final fun equals-impl0 (BB)Z
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode (B)I public static fun hashCode-impl (B)I
public static final fun inc (B)B public static final fun inc-impl (B)B
public static final fun inv (B)B public static final fun inv-impl (B)B
public static final fun minus-4n0qz0s4 (BJ)J public static final fun minus-7apg3OU (BB)I
public static final fun minus-4wtlwgkb (BI)I public static final fun minus-VKZWuLQ (BJ)J
public static final fun minus-av578izg (BS)I public static final fun minus-WZ4Q5Ns (BI)I
public static final fun minus-d0xlk1d1 (BB)I public static final fun minus-xj2QHRw (BS)I
public static final fun or-d0xlk1d1 (BB)B public static final fun or-7apg3OU (BB)B
public static final fun plus-4n0qz0s4 (BJ)J public static final fun plus-7apg3OU (BB)I
public static final fun plus-4wtlwgkb (BI)I public static final fun plus-VKZWuLQ (BJ)J
public static final fun plus-av578izg (BS)I public static final fun plus-WZ4Q5Ns (BI)I
public static final fun plus-d0xlk1d1 (BB)I public static final fun plus-xj2QHRw (BS)I
public static final fun rangeTo-d0xlk1d1 (BB)Lkotlin/ranges/UIntRange; public static final fun rangeTo-7apg3OU (BB)Lkotlin/ranges/UIntRange;
public static final fun rem-4n0qz0s4 (BJ)J public static final fun rem-7apg3OU (BB)I
public static final fun rem-4wtlwgkb (BI)I public static final fun rem-VKZWuLQ (BJ)J
public static final fun rem-av578izg (BS)I public static final fun rem-WZ4Q5Ns (BI)I
public static final fun rem-d0xlk1d1 (BB)I public static final fun rem-xj2QHRw (BS)I
public static final fun times-4n0qz0s4 (BJ)J public static final fun times-7apg3OU (BB)I
public static final fun times-4wtlwgkb (BI)I public static final fun times-VKZWuLQ (BJ)J
public static final fun times-av578izg (BS)I public static final fun times-WZ4Q5Ns (BI)I
public static final fun times-d0xlk1d1 (BB)I public static final fun times-xj2QHRw (BS)I
public static final fun toByte (B)B public static final fun toByte-impl (B)B
public static final fun toInt (B)I public static final fun toInt-impl (B)I
public static final fun toLong (B)J public static final fun toLong-impl (B)J
public static final fun toShort (B)S public static final fun toShort-impl (B)S
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString (B)Ljava/lang/String; public static fun toString-impl (B)Ljava/lang/String;
public static final fun toUByte (B)B public static final fun toUByte-impl (B)B
public static final fun toUInt (B)I public static final fun toUInt-impl (B)I
public static final fun toULong (B)J public static final fun toULong-impl (B)J
public static final fun toUShort (B)S public static final fun toUShort-impl (B)S
public final fun unbox ()B public final synthetic fun unbox-impl ()B
public static final fun xor-d0xlk1d1 (BB)B public static final fun xor-7apg3OU (BB)B
} }
public final class kotlin/UByte$Companion { public final class kotlin/UByte$Companion {
} }
public final class kotlin/UByteArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker { public final class kotlin/UByteArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker {
public synthetic fun <init> ([B)V
public synthetic fun add (Ljava/lang/Object;)Z public synthetic fun add (Ljava/lang/Object;)Z
public fun add-d0xlk1d1 (B)Z public fun add-7apg3OU (B)Z
public fun addAll (Ljava/util/Collection;)Z public fun addAll (Ljava/util/Collection;)Z
public static final fun box ([B)Lkotlin/UByteArray; public static final synthetic fun box-impl ([B)Lkotlin/UByteArray;
public fun clear ()V public fun clear ()V
public static fun constructor (I)[B public static fun constructor-impl (I)[B
public static fun constructor ([B)[B public static fun constructor-impl ([B)[B
public final fun contains (Ljava/lang/Object;)Z public final fun contains (Ljava/lang/Object;)Z
public fun contains-d0xlk1d1 (B)Z public fun contains-7apg3OU (B)Z
public static fun contains-d0xlk1d1 ([BB)Z public static fun contains-7apg3OU ([BB)Z
public fun containsAll (Ljava/util/Collection;)Z public fun containsAll (Ljava/util/Collection;)Z
public static fun containsAll ([BLjava/util/Collection;)Z public static fun containsAll-impl ([BLjava/util/Collection;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals ([BLjava/lang/Object;)Z public static fun equals-impl ([BLjava/lang/Object;)Z
public static final fun get ([BI)B public static final fun equals-impl0 ([B[B)Z
public static final fun get-impl ([BI)B
public fun getSize ()I public fun getSize ()I
public static fun getSize ([B)I public static fun getSize-impl ([B)I
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode ([B)I public static fun hashCode-impl ([B)I
public fun isEmpty ()Z public fun isEmpty ()Z
public static fun isEmpty ([B)Z public static fun isEmpty-impl ([B)Z
public synthetic fun iterator ()Ljava/util/Iterator; public synthetic fun iterator ()Ljava/util/Iterator;
public fun iterator ()Lkotlin/collections/UByteIterator; public fun iterator ()Lkotlin/collections/UByteIterator;
public static fun iterator ([B)Lkotlin/collections/UByteIterator; public static fun iterator-impl ([B)Lkotlin/collections/UByteIterator;
public fun remove (Ljava/lang/Object;)Z public fun remove (Ljava/lang/Object;)Z
public fun removeAll (Ljava/util/Collection;)Z public fun removeAll (Ljava/util/Collection;)Z
public fun retainAll (Ljava/util/Collection;)Z public fun retainAll (Ljava/util/Collection;)Z
public static final fun set-4rhu7tbx ([BIB)V public static final fun set-VurrAj0 ([BIB)V
public final fun size ()I public final fun size ()I
public fun toArray ()[Ljava/lang/Object; public fun toArray ()[Ljava/lang/Object;
public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString ([B)Ljava/lang/String; public static fun toString-impl ([B)Ljava/lang/String;
public final fun unbox ()[B public final synthetic fun unbox-impl ()[B
} }
public final class kotlin/UByteKt { public final class kotlin/UByteKt {
@@ -321,99 +344,100 @@ public final class kotlin/UInt : java/lang/Comparable {
public static final field MIN_VALUE I public static final field MIN_VALUE I
public static final field SIZE_BITS I public static final field SIZE_BITS I
public static final field SIZE_BYTES I public static final field SIZE_BYTES I
public static final fun and-4wtlwgkb (II)I public static final fun and-WZ4Q5Ns (II)I
public static final fun box (I)Lkotlin/UInt; public static final synthetic fun box-impl (I)Lkotlin/UInt;
public synthetic fun compareTo (Ljava/lang/Object;)I public synthetic fun compareTo (Ljava/lang/Object;)I
public static final fun compareTo-4n0qz0s4 (IJ)I public static final fun compareTo-7apg3OU (IB)I
public fun compareTo-4wtlwgkb (I)I public static final fun compareTo-VKZWuLQ (IJ)I
public static fun compareTo-4wtlwgkb (II)I public fun compareTo-WZ4Q5Ns (I)I
public static final fun compareTo-av578izg (IS)I public static fun compareTo-WZ4Q5Ns (II)I
public static final fun compareTo-d0xlk1d1 (IB)I public static final fun compareTo-xj2QHRw (IS)I
public static fun constructor (I)I public static fun constructor-impl (I)I
public static final fun dec (I)I public static final fun dec-impl (I)I
public static final fun div-4n0qz0s4 (IJ)J public static final fun div-7apg3OU (IB)I
public static final fun div-4wtlwgkb (II)I public static final fun div-VKZWuLQ (IJ)J
public static final fun div-av578izg (IS)I public static final fun div-WZ4Q5Ns (II)I
public static final fun div-d0xlk1d1 (IB)I public static final fun div-xj2QHRw (IS)I
public static fun equals (ILjava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (ILjava/lang/Object;)Z
public static final fun equals-impl0 (II)Z
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode (I)I public static fun hashCode-impl (I)I
public static final fun inc (I)I public static final fun inc-impl (I)I
public static final fun inv (I)I public static final fun inv-impl (I)I
public static final fun minus-4n0qz0s4 (IJ)J public static final fun minus-7apg3OU (IB)I
public static final fun minus-4wtlwgkb (II)I public static final fun minus-VKZWuLQ (IJ)J
public static final fun minus-av578izg (IS)I public static final fun minus-WZ4Q5Ns (II)I
public static final fun minus-d0xlk1d1 (IB)I public static final fun minus-xj2QHRw (IS)I
public static final fun or-4wtlwgkb (II)I public static final fun or-WZ4Q5Ns (II)I
public static final fun plus-4n0qz0s4 (IJ)J public static final fun plus-7apg3OU (IB)I
public static final fun plus-4wtlwgkb (II)I public static final fun plus-VKZWuLQ (IJ)J
public static final fun plus-av578izg (IS)I public static final fun plus-WZ4Q5Ns (II)I
public static final fun plus-d0xlk1d1 (IB)I public static final fun plus-xj2QHRw (IS)I
public static final fun rangeTo-4wtlwgkb (II)Lkotlin/ranges/UIntRange; public static final fun rangeTo-WZ4Q5Ns (II)Lkotlin/ranges/UIntRange;
public static final fun rem-4n0qz0s4 (IJ)J public static final fun rem-7apg3OU (IB)I
public static final fun rem-4wtlwgkb (II)I public static final fun rem-VKZWuLQ (IJ)J
public static final fun rem-av578izg (IS)I public static final fun rem-WZ4Q5Ns (II)I
public static final fun rem-d0xlk1d1 (IB)I public static final fun rem-xj2QHRw (IS)I
public static final fun shl (II)I public static final fun shl-impl (II)I
public static final fun shr (II)I public static final fun shr-impl (II)I
public static final fun times-4n0qz0s4 (IJ)J public static final fun times-7apg3OU (IB)I
public static final fun times-4wtlwgkb (II)I public static final fun times-VKZWuLQ (IJ)J
public static final fun times-av578izg (IS)I public static final fun times-WZ4Q5Ns (II)I
public static final fun times-d0xlk1d1 (IB)I public static final fun times-xj2QHRw (IS)I
public static final fun toByte (I)B public static final fun toByte-impl (I)B
public static final fun toInt (I)I public static final fun toInt-impl (I)I
public static final fun toLong (I)J public static final fun toLong-impl (I)J
public static final fun toShort (I)S public static final fun toShort-impl (I)S
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString (I)Ljava/lang/String; public static fun toString-impl (I)Ljava/lang/String;
public static final fun toUByte (I)B public static final fun toUByte-impl (I)B
public static final fun toUInt (I)I public static final fun toUInt-impl (I)I
public static final fun toULong (I)J public static final fun toULong-impl (I)J
public static final fun toUShort (I)S public static final fun toUShort-impl (I)S
public final fun unbox ()I public final synthetic fun unbox-impl ()I
public static final fun xor-4wtlwgkb (II)I public static final fun xor-WZ4Q5Ns (II)I
} }
public final class kotlin/UInt$Companion { public final class kotlin/UInt$Companion {
} }
public final class kotlin/UIntArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker { public final class kotlin/UIntArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker {
public synthetic fun <init> ([I)V
public synthetic fun add (Ljava/lang/Object;)Z public synthetic fun add (Ljava/lang/Object;)Z
public fun add-4wtlwgkb (I)Z public fun add-WZ4Q5Ns (I)Z
public fun addAll (Ljava/util/Collection;)Z public fun addAll (Ljava/util/Collection;)Z
public static final fun box ([I)Lkotlin/UIntArray; public static final synthetic fun box-impl ([I)Lkotlin/UIntArray;
public fun clear ()V public fun clear ()V
public static fun constructor (I)[I public static fun constructor-impl (I)[I
public static fun constructor ([I)[I public static fun constructor-impl ([I)[I
public final fun contains (Ljava/lang/Object;)Z public final fun contains (Ljava/lang/Object;)Z
public fun contains-4wtlwgkb (I)Z public fun contains-WZ4Q5Ns (I)Z
public static fun contains-4wtlwgkb ([II)Z public static fun contains-WZ4Q5Ns ([II)Z
public fun containsAll (Ljava/util/Collection;)Z public fun containsAll (Ljava/util/Collection;)Z
public static fun containsAll ([ILjava/util/Collection;)Z public static fun containsAll-impl ([ILjava/util/Collection;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals ([ILjava/lang/Object;)Z public static fun equals-impl ([ILjava/lang/Object;)Z
public static final fun get ([II)I public static final fun equals-impl0 ([I[I)Z
public static final fun get-impl ([II)I
public fun getSize ()I public fun getSize ()I
public static fun getSize ([I)I public static fun getSize-impl ([I)I
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode ([I)I public static fun hashCode-impl ([I)I
public fun isEmpty ()Z public fun isEmpty ()Z
public static fun isEmpty ([I)Z public static fun isEmpty-impl ([I)Z
public synthetic fun iterator ()Ljava/util/Iterator; public synthetic fun iterator ()Ljava/util/Iterator;
public fun iterator ()Lkotlin/collections/UIntIterator; public fun iterator ()Lkotlin/collections/UIntIterator;
public static fun iterator ([I)Lkotlin/collections/UIntIterator; public static fun iterator-impl ([I)Lkotlin/collections/UIntIterator;
public fun remove (Ljava/lang/Object;)Z public fun remove (Ljava/lang/Object;)Z
public fun removeAll (Ljava/util/Collection;)Z public fun removeAll (Ljava/util/Collection;)Z
public fun retainAll (Ljava/util/Collection;)Z public fun retainAll (Ljava/util/Collection;)Z
public static final fun set-4olz5s4v ([III)V public static final fun set-VXSXFK8 ([III)V
public final fun size ()I public final fun size ()I
public fun toArray ()[Ljava/lang/Object; public fun toArray ()[Ljava/lang/Object;
public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString ([I)Ljava/lang/String; public static fun toString-impl ([I)Ljava/lang/String;
public final fun unbox ()[I public final synthetic fun unbox-impl ()[I
} }
public final class kotlin/UIntKt { public final class kotlin/UIntKt {
@@ -429,99 +453,100 @@ public final class kotlin/ULong : java/lang/Comparable {
public static final field MIN_VALUE J public static final field MIN_VALUE J
public static final field SIZE_BITS I public static final field SIZE_BITS I
public static final field SIZE_BYTES I public static final field SIZE_BYTES I
public static final fun and-4n0qz0s4 (JJ)J public static final fun and-VKZWuLQ (JJ)J
public static final fun box (J)Lkotlin/ULong; public static final synthetic fun box-impl (J)Lkotlin/ULong;
public synthetic fun compareTo (Ljava/lang/Object;)I public synthetic fun compareTo (Ljava/lang/Object;)I
public fun compareTo-4n0qz0s4 (J)I public static final fun compareTo-7apg3OU (JB)I
public static fun compareTo-4n0qz0s4 (JJ)I public fun compareTo-VKZWuLQ (J)I
public static final fun compareTo-4wtlwgkb (JI)I public static fun compareTo-VKZWuLQ (JJ)I
public static final fun compareTo-av578izg (JS)I public static final fun compareTo-WZ4Q5Ns (JI)I
public static final fun compareTo-d0xlk1d1 (JB)I public static final fun compareTo-xj2QHRw (JS)I
public static fun constructor (J)J public static fun constructor-impl (J)J
public static final fun dec (J)J public static final fun dec-impl (J)J
public static final fun div-4n0qz0s4 (JJ)J public static final fun div-7apg3OU (JB)J
public static final fun div-4wtlwgkb (JI)J public static final fun div-VKZWuLQ (JJ)J
public static final fun div-av578izg (JS)J public static final fun div-WZ4Q5Ns (JI)J
public static final fun div-d0xlk1d1 (JB)J public static final fun div-xj2QHRw (JS)J
public static fun equals (JLjava/lang/Object;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (JLjava/lang/Object;)Z
public static final fun equals-impl0 (JJ)Z
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode (J)I public static fun hashCode-impl (J)I
public static final fun inc (J)J public static final fun inc-impl (J)J
public static final fun inv (J)J public static final fun inv-impl (J)J
public static final fun minus-4n0qz0s4 (JJ)J public static final fun minus-7apg3OU (JB)J
public static final fun minus-4wtlwgkb (JI)J public static final fun minus-VKZWuLQ (JJ)J
public static final fun minus-av578izg (JS)J public static final fun minus-WZ4Q5Ns (JI)J
public static final fun minus-d0xlk1d1 (JB)J public static final fun minus-xj2QHRw (JS)J
public static final fun or-4n0qz0s4 (JJ)J public static final fun or-VKZWuLQ (JJ)J
public static final fun plus-4n0qz0s4 (JJ)J public static final fun plus-7apg3OU (JB)J
public static final fun plus-4wtlwgkb (JI)J public static final fun plus-VKZWuLQ (JJ)J
public static final fun plus-av578izg (JS)J public static final fun plus-WZ4Q5Ns (JI)J
public static final fun plus-d0xlk1d1 (JB)J public static final fun plus-xj2QHRw (JS)J
public static final fun rangeTo-4n0qz0s4 (JJ)Lkotlin/ranges/ULongRange; public static final fun rangeTo-VKZWuLQ (JJ)Lkotlin/ranges/ULongRange;
public static final fun rem-4n0qz0s4 (JJ)J public static final fun rem-7apg3OU (JB)J
public static final fun rem-4wtlwgkb (JI)J public static final fun rem-VKZWuLQ (JJ)J
public static final fun rem-av578izg (JS)J public static final fun rem-WZ4Q5Ns (JI)J
public static final fun rem-d0xlk1d1 (JB)J public static final fun rem-xj2QHRw (JS)J
public static final fun shl (JI)J public static final fun shl-impl (JI)J
public static final fun shr (JI)J public static final fun shr-impl (JI)J
public static final fun times-4n0qz0s4 (JJ)J public static final fun times-7apg3OU (JB)J
public static final fun times-4wtlwgkb (JI)J public static final fun times-VKZWuLQ (JJ)J
public static final fun times-av578izg (JS)J public static final fun times-WZ4Q5Ns (JI)J
public static final fun times-d0xlk1d1 (JB)J public static final fun times-xj2QHRw (JS)J
public static final fun toByte (J)B public static final fun toByte-impl (J)B
public static final fun toInt (J)I public static final fun toInt-impl (J)I
public static final fun toLong (J)J public static final fun toLong-impl (J)J
public static final fun toShort (J)S public static final fun toShort-impl (J)S
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString (J)Ljava/lang/String; public static fun toString-impl (J)Ljava/lang/String;
public static final fun toUByte (J)B public static final fun toUByte-impl (J)B
public static final fun toUInt (J)I public static final fun toUInt-impl (J)I
public static final fun toULong (J)J public static final fun toULong-impl (J)J
public static final fun toUShort (J)S public static final fun toUShort-impl (J)S
public final fun unbox ()J public final synthetic fun unbox-impl ()J
public static final fun xor-4n0qz0s4 (JJ)J public static final fun xor-VKZWuLQ (JJ)J
} }
public final class kotlin/ULong$Companion { public final class kotlin/ULong$Companion {
} }
public final class kotlin/ULongArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker { public final class kotlin/ULongArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker {
public synthetic fun <init> ([J)V
public synthetic fun add (Ljava/lang/Object;)Z public synthetic fun add (Ljava/lang/Object;)Z
public fun add-4n0qz0s4 (J)Z public fun add-VKZWuLQ (J)Z
public fun addAll (Ljava/util/Collection;)Z public fun addAll (Ljava/util/Collection;)Z
public static final fun box ([J)Lkotlin/ULongArray; public static final synthetic fun box-impl ([J)Lkotlin/ULongArray;
public fun clear ()V public fun clear ()V
public static fun constructor (I)[J public static fun constructor-impl (I)[J
public static fun constructor ([J)[J public static fun constructor-impl ([J)[J
public final fun contains (Ljava/lang/Object;)Z public final fun contains (Ljava/lang/Object;)Z
public fun contains-4n0qz0s4 (J)Z public fun contains-VKZWuLQ (J)Z
public static fun contains-4n0qz0s4 ([JJ)Z public static fun contains-VKZWuLQ ([JJ)Z
public fun containsAll (Ljava/util/Collection;)Z public fun containsAll (Ljava/util/Collection;)Z
public static fun containsAll ([JLjava/util/Collection;)Z public static fun containsAll-impl ([JLjava/util/Collection;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals ([JLjava/lang/Object;)Z public static fun equals-impl ([JLjava/lang/Object;)Z
public static final fun get ([JI)J public static final fun equals-impl0 ([J[J)Z
public static final fun get-impl ([JI)J
public fun getSize ()I public fun getSize ()I
public static fun getSize ([J)I public static fun getSize-impl ([J)I
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode ([J)I public static fun hashCode-impl ([J)I
public fun isEmpty ()Z public fun isEmpty ()Z
public static fun isEmpty ([J)Z public static fun isEmpty-impl ([J)Z
public synthetic fun iterator ()Ljava/util/Iterator; public synthetic fun iterator ()Ljava/util/Iterator;
public fun iterator ()Lkotlin/collections/ULongIterator; public fun iterator ()Lkotlin/collections/ULongIterator;
public static fun iterator ([J)Lkotlin/collections/ULongIterator; public static fun iterator-impl ([J)Lkotlin/collections/ULongIterator;
public fun remove (Ljava/lang/Object;)Z public fun remove (Ljava/lang/Object;)Z
public fun removeAll (Ljava/util/Collection;)Z public fun removeAll (Ljava/util/Collection;)Z
public fun retainAll (Ljava/util/Collection;)Z public fun retainAll (Ljava/util/Collection;)Z
public static final fun set-83j4ar8e ([JIJ)V public static final fun set-k8EXiF4 ([JIJ)V
public final fun size ()I public final fun size ()I
public fun toArray ()[Ljava/lang/Object; public fun toArray ()[Ljava/lang/Object;
public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString ([J)Ljava/lang/String; public static fun toString-impl ([J)Ljava/lang/String;
public final fun unbox ()[J public final synthetic fun unbox-impl ()[J
} }
public final class kotlin/ULongKt { public final class kotlin/ULongKt {
@@ -537,97 +562,98 @@ public final class kotlin/UShort : java/lang/Comparable {
public static final field MIN_VALUE S public static final field MIN_VALUE S
public static final field SIZE_BITS I public static final field SIZE_BITS I
public static final field SIZE_BYTES I public static final field SIZE_BYTES I
public static final fun and-av578izg (SS)S public static final fun and-xj2QHRw (SS)S
public static final fun box (S)Lkotlin/UShort; public static final synthetic fun box-impl (S)Lkotlin/UShort;
public synthetic fun compareTo (Ljava/lang/Object;)I public synthetic fun compareTo (Ljava/lang/Object;)I
public static final fun compareTo-4n0qz0s4 (SJ)I public static final fun compareTo-7apg3OU (SB)I
public static final fun compareTo-4wtlwgkb (SI)I public static final fun compareTo-VKZWuLQ (SJ)I
public fun compareTo-av578izg (S)I public static final fun compareTo-WZ4Q5Ns (SI)I
public static fun compareTo-av578izg (SS)I public fun compareTo-xj2QHRw (S)I
public static final fun compareTo-d0xlk1d1 (SB)I public static fun compareTo-xj2QHRw (SS)I
public static fun constructor (S)S public static fun constructor-impl (S)S
public static final fun dec (S)S public static final fun dec-impl (S)S
public static final fun div-4n0qz0s4 (SJ)J public static final fun div-7apg3OU (SB)I
public static final fun div-4wtlwgkb (SI)I public static final fun div-VKZWuLQ (SJ)J
public static final fun div-av578izg (SS)I public static final fun div-WZ4Q5Ns (SI)I
public static final fun div-d0xlk1d1 (SB)I public static final fun div-xj2QHRw (SS)I
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals (SLjava/lang/Object;)Z public static fun equals-impl (SLjava/lang/Object;)Z
public static final fun equals-impl0 (SS)Z
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode (S)I public static fun hashCode-impl (S)I
public static final fun inc (S)S public static final fun inc-impl (S)S
public static final fun inv (S)S public static final fun inv-impl (S)S
public static final fun minus-4n0qz0s4 (SJ)J public static final fun minus-7apg3OU (SB)I
public static final fun minus-4wtlwgkb (SI)I public static final fun minus-VKZWuLQ (SJ)J
public static final fun minus-av578izg (SS)I public static final fun minus-WZ4Q5Ns (SI)I
public static final fun minus-d0xlk1d1 (SB)I public static final fun minus-xj2QHRw (SS)I
public static final fun or-av578izg (SS)S public static final fun or-xj2QHRw (SS)S
public static final fun plus-4n0qz0s4 (SJ)J public static final fun plus-7apg3OU (SB)I
public static final fun plus-4wtlwgkb (SI)I public static final fun plus-VKZWuLQ (SJ)J
public static final fun plus-av578izg (SS)I public static final fun plus-WZ4Q5Ns (SI)I
public static final fun plus-d0xlk1d1 (SB)I public static final fun plus-xj2QHRw (SS)I
public static final fun rangeTo-av578izg (SS)Lkotlin/ranges/UIntRange; public static final fun rangeTo-xj2QHRw (SS)Lkotlin/ranges/UIntRange;
public static final fun rem-4n0qz0s4 (SJ)J public static final fun rem-7apg3OU (SB)I
public static final fun rem-4wtlwgkb (SI)I public static final fun rem-VKZWuLQ (SJ)J
public static final fun rem-av578izg (SS)I public static final fun rem-WZ4Q5Ns (SI)I
public static final fun rem-d0xlk1d1 (SB)I public static final fun rem-xj2QHRw (SS)I
public static final fun times-4n0qz0s4 (SJ)J public static final fun times-7apg3OU (SB)I
public static final fun times-4wtlwgkb (SI)I public static final fun times-VKZWuLQ (SJ)J
public static final fun times-av578izg (SS)I public static final fun times-WZ4Q5Ns (SI)I
public static final fun times-d0xlk1d1 (SB)I public static final fun times-xj2QHRw (SS)I
public static final fun toByte (S)B public static final fun toByte-impl (S)B
public static final fun toInt (S)I public static final fun toInt-impl (S)I
public static final fun toLong (S)J public static final fun toLong-impl (S)J
public static final fun toShort (S)S public static final fun toShort-impl (S)S
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString (S)Ljava/lang/String; public static fun toString-impl (S)Ljava/lang/String;
public static final fun toUByte (S)B public static final fun toUByte-impl (S)B
public static final fun toUInt (S)I public static final fun toUInt-impl (S)I
public static final fun toULong (S)J public static final fun toULong-impl (S)J
public static final fun toUShort (S)S public static final fun toUShort-impl (S)S
public final fun unbox ()S public final synthetic fun unbox-impl ()S
public static final fun xor-av578izg (SS)S public static final fun xor-xj2QHRw (SS)S
} }
public final class kotlin/UShort$Companion { public final class kotlin/UShort$Companion {
} }
public final class kotlin/UShortArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker { public final class kotlin/UShortArray : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker {
public synthetic fun <init> ([S)V
public synthetic fun add (Ljava/lang/Object;)Z public synthetic fun add (Ljava/lang/Object;)Z
public fun add-av578izg (S)Z public fun add-xj2QHRw (S)Z
public fun addAll (Ljava/util/Collection;)Z public fun addAll (Ljava/util/Collection;)Z
public static final fun box ([S)Lkotlin/UShortArray; public static final synthetic fun box-impl ([S)Lkotlin/UShortArray;
public fun clear ()V public fun clear ()V
public static fun constructor (I)[S public static fun constructor-impl (I)[S
public static fun constructor ([S)[S public static fun constructor-impl ([S)[S
public final fun contains (Ljava/lang/Object;)Z public final fun contains (Ljava/lang/Object;)Z
public fun contains-av578izg (S)Z public fun contains-xj2QHRw (S)Z
public static fun contains-av578izg ([SS)Z public static fun contains-xj2QHRw ([SS)Z
public fun containsAll (Ljava/util/Collection;)Z public fun containsAll (Ljava/util/Collection;)Z
public static fun containsAll ([SLjava/util/Collection;)Z public static fun containsAll-impl ([SLjava/util/Collection;)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public static fun equals ([SLjava/lang/Object;)Z public static fun equals-impl ([SLjava/lang/Object;)Z
public static final fun get ([SI)S public static final fun equals-impl0 ([S[S)Z
public static final fun get-impl ([SI)S
public fun getSize ()I public fun getSize ()I
public static fun getSize ([S)I public static fun getSize-impl ([S)I
public fun hashCode ()I public fun hashCode ()I
public static fun hashCode ([S)I public static fun hashCode-impl ([S)I
public fun isEmpty ()Z public fun isEmpty ()Z
public static fun isEmpty ([S)Z public static fun isEmpty-impl ([S)Z
public synthetic fun iterator ()Ljava/util/Iterator; public synthetic fun iterator ()Ljava/util/Iterator;
public fun iterator ()Lkotlin/collections/UShortIterator; public fun iterator ()Lkotlin/collections/UShortIterator;
public static fun iterator ([S)Lkotlin/collections/UShortIterator; public static fun iterator-impl ([S)Lkotlin/collections/UShortIterator;
public fun remove (Ljava/lang/Object;)Z public fun remove (Ljava/lang/Object;)Z
public fun removeAll (Ljava/util/Collection;)Z public fun removeAll (Ljava/util/Collection;)Z
public fun retainAll (Ljava/util/Collection;)Z public fun retainAll (Ljava/util/Collection;)Z
public static final fun set-bky83bo1 ([SIS)V public static final fun set-01HTLdE ([SIS)V
public final fun size ()I public final fun size ()I
public fun toArray ()[Ljava/lang/Object; public fun toArray ()[Ljava/lang/Object;
public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
public static fun toString ([S)Ljava/lang/String; public static fun toString-impl ([S)Ljava/lang/String;
public final fun unbox ()[S public final synthetic fun unbox-impl ()[S
} }
public final class kotlin/UShortKt { public final class kotlin/UShortKt {
@@ -2460,26 +2486,26 @@ public abstract class kotlin/collections/ShortIterator : java/util/Iterator, kot
} }
public final class kotlin/collections/UArraysKt { public final class kotlin/collections/UArraysKt {
public static final fun contentEquals-6ajjrs7m ([I[I)Z public static final fun contentEquals-ctEhBpI ([I[I)Z
public static final fun contentEquals-7zqa7xiz ([B[B)Z public static final fun contentEquals-kdPth3s ([B[B)Z
public static final fun contentEquals-8f7oupw0 ([S[S)Z public static final fun contentEquals-mazbYpA ([S[S)Z
public static final fun contentEquals-a8l8huwo ([J[J)Z public static final fun contentEquals-us8wMrg ([J[J)Z
public static final fun contentHashCode-1biuymyp ([B)I public static final fun contentHashCode--ajY-9A ([I)I
public static final fun contentHashCode-3o8tnvbt ([J)I public static final fun contentHashCode-GBYM_sE ([B)I
public static final fun contentHashCode-9gu3s6ig ([S)I public static final fun contentHashCode-QwZRm1k ([J)I
public static final fun contentHashCode-doljm8k0 ([I)I public static final fun contentHashCode-rL5Bavg ([S)I
public static final fun contentToString-1biuymyp ([B)Ljava/lang/String; public static final fun contentToString--ajY-9A ([I)Ljava/lang/String;
public static final fun contentToString-3o8tnvbt ([J)Ljava/lang/String; public static final fun contentToString-GBYM_sE ([B)Ljava/lang/String;
public static final fun contentToString-9gu3s6ig ([S)Ljava/lang/String; public static final fun contentToString-QwZRm1k ([J)Ljava/lang/String;
public static final fun contentToString-doljm8k0 ([I)Ljava/lang/String; public static final fun contentToString-rL5Bavg ([S)Ljava/lang/String;
public static final fun random-25eqzsg0 ([JLkotlin/random/Random;)J public static final fun random-2D5oskM ([ILkotlin/random/Random;)I
public static final fun random-8tx9e8n3 ([BLkotlin/random/Random;)B public static final fun random-JzugnMA ([JLkotlin/random/Random;)J
public static final fun random-9uc5g3in ([SLkotlin/random/Random;)S public static final fun random-oSF2wD8 ([BLkotlin/random/Random;)B
public static final fun random-bunzpqo3 ([ILkotlin/random/Random;)I public static final fun random-s5X_as8 ([SLkotlin/random/Random;)S
public static final fun toTypedArray-1biuymyp ([B)[Lkotlin/UByte; public static final fun toTypedArray--ajY-9A ([I)[Lkotlin/UInt;
public static final fun toTypedArray-3o8tnvbt ([J)[Lkotlin/ULong; public static final fun toTypedArray-GBYM_sE ([B)[Lkotlin/UByte;
public static final fun toTypedArray-9gu3s6ig ([S)[Lkotlin/UShort; public static final fun toTypedArray-QwZRm1k ([J)[Lkotlin/ULong;
public static final fun toTypedArray-doljm8k0 ([I)[Lkotlin/UInt; public static final fun toTypedArray-rL5Bavg ([S)[Lkotlin/UShort;
} }
public abstract class kotlin/collections/UByteIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker { public abstract class kotlin/collections/UByteIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker {
@@ -2841,8 +2867,8 @@ public final class kotlin/internal/ProgressionUtilKt {
} }
public final class kotlin/internal/UProgressionUtilKt { public final class kotlin/internal/UProgressionUtilKt {
public static final fun getProgressionLastElement-2z3rwsob (III)I public static final fun getProgressionLastElement-7ftBX0g (JJJ)J
public static final fun getProgressionLastElement-d1k1ewy0 (JJJ)J public static final fun getProgressionLastElement-Nkh28Cs (III)I
} }
public final class kotlin/io/AccessDeniedException : kotlin/io/FileSystemException { public final class kotlin/io/AccessDeniedException : kotlin/io/FileSystemException {
@@ -3907,17 +3933,17 @@ public final class kotlin/random/RandomKt {
public static final fun Random (I)Lkotlin/random/Random; public static final fun Random (I)Lkotlin/random/Random;
public static final fun Random (J)Lkotlin/random/Random; public static final fun Random (J)Lkotlin/random/Random;
public static final fun nextUBytes (Lkotlin/random/Random;I)[B public static final fun nextUBytes (Lkotlin/random/Random;I)[B
public static final fun nextUBytes-4zielkbi (Lkotlin/random/Random;[BII)[B public static final fun nextUBytes-EVgfTAA (Lkotlin/random/Random;[B)[B
public static synthetic fun nextUBytes-4zielkbi$default (Lkotlin/random/Random;[BIIILjava/lang/Object;)[B public static final fun nextUBytes-Wvrt4B4 (Lkotlin/random/Random;[BII)[B
public static final fun nextUBytes-y7z55vk (Lkotlin/random/Random;[B)[B public static synthetic fun nextUBytes-Wvrt4B4$default (Lkotlin/random/Random;[BIIILjava/lang/Object;)[B
public static final fun nextUInt (Lkotlin/random/Random;)I public static final fun nextUInt (Lkotlin/random/Random;)I
public static final fun nextUInt (Lkotlin/random/Random;Lkotlin/ranges/UIntRange;)I public static final fun nextUInt (Lkotlin/random/Random;Lkotlin/ranges/UIntRange;)I
public static final fun nextUInt-5wlsgfq1 (Lkotlin/random/Random;II)I public static final fun nextUInt-a8DCA5k (Lkotlin/random/Random;II)I
public static final fun nextUInt-97rx7kg5 (Lkotlin/random/Random;I)I public static final fun nextUInt-qCasIEU (Lkotlin/random/Random;I)I
public static final fun nextULong (Lkotlin/random/Random;)J public static final fun nextULong (Lkotlin/random/Random;)J
public static final fun nextULong (Lkotlin/random/Random;Lkotlin/ranges/ULongRange;)J public static final fun nextULong (Lkotlin/random/Random;Lkotlin/ranges/ULongRange;)J
public static final fun nextULong-4sbioyd2 (Lkotlin/random/Random;J)J public static final fun nextULong-V1Xi4fY (Lkotlin/random/Random;J)J
public static final fun nextULong-7szwbobr (Lkotlin/random/Random;JJ)J public static final fun nextULong-jmpaW-c (Lkotlin/random/Random;JJ)J
} }
public class kotlin/ranges/CharProgression : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker { public class kotlin/ranges/CharProgression : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
@@ -4157,6 +4183,7 @@ public final class kotlin/ranges/RangesKt {
public class kotlin/ranges/UIntProgression : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker { public class kotlin/ranges/UIntProgression : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
public static final field Companion Lkotlin/ranges/UIntProgression$Companion; public static final field Companion Lkotlin/ranges/UIntProgression$Companion;
public synthetic fun <init> (IIILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public final fun getFirst ()I public final fun getFirst ()I
public final fun getLast ()I public final fun getLast ()I
@@ -4169,14 +4196,14 @@ public class kotlin/ranges/UIntProgression : java/lang/Iterable, kotlin/jvm/inte
} }
public final class kotlin/ranges/UIntProgression$Companion { public final class kotlin/ranges/UIntProgression$Companion {
public final fun fromClosedRange-2z3rwsob (III)Lkotlin/ranges/UIntProgression; public final fun fromClosedRange-Nkh28Cs (III)Lkotlin/ranges/UIntProgression;
} }
public final class kotlin/ranges/UIntRange : kotlin/ranges/UIntProgression, kotlin/ranges/ClosedRange { public final class kotlin/ranges/UIntRange : kotlin/ranges/UIntProgression, kotlin/ranges/ClosedRange {
public static final field Companion Lkotlin/ranges/UIntRange$Companion; public static final field Companion Lkotlin/ranges/UIntRange$Companion;
public fun <init> (II)V public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun contains (Ljava/lang/Comparable;)Z public synthetic fun contains (Ljava/lang/Comparable;)Z
public fun contains-4wtlwgkb (I)Z public fun contains-WZ4Q5Ns (I)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public synthetic fun getEndInclusive ()Ljava/lang/Comparable; public synthetic fun getEndInclusive ()Ljava/lang/Comparable;
public fun getEndInclusive ()Lkotlin/UInt; public fun getEndInclusive ()Lkotlin/UInt;
@@ -4193,6 +4220,7 @@ public final class kotlin/ranges/UIntRange$Companion {
public class kotlin/ranges/ULongProgression : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker { public class kotlin/ranges/ULongProgression : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
public static final field Companion Lkotlin/ranges/ULongProgression$Companion; public static final field Companion Lkotlin/ranges/ULongProgression$Companion;
public synthetic fun <init> (JJJLkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public final fun getFirst ()J public final fun getFirst ()J
public final fun getLast ()J public final fun getLast ()J
@@ -4205,14 +4233,14 @@ public class kotlin/ranges/ULongProgression : java/lang/Iterable, kotlin/jvm/int
} }
public final class kotlin/ranges/ULongProgression$Companion { public final class kotlin/ranges/ULongProgression$Companion {
public final fun fromClosedRange-d1k1ewy0 (JJJ)Lkotlin/ranges/ULongProgression; public final fun fromClosedRange-7ftBX0g (JJJ)Lkotlin/ranges/ULongProgression;
} }
public final class kotlin/ranges/ULongRange : kotlin/ranges/ULongProgression, kotlin/ranges/ClosedRange { public final class kotlin/ranges/ULongRange : kotlin/ranges/ULongProgression, kotlin/ranges/ClosedRange {
public static final field Companion Lkotlin/ranges/ULongRange$Companion; public static final field Companion Lkotlin/ranges/ULongRange$Companion;
public fun <init> (JJ)V public synthetic fun <init> (JJLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun contains (Ljava/lang/Comparable;)Z public synthetic fun contains (Ljava/lang/Comparable;)Z
public fun contains-4n0qz0s4 (J)Z public fun contains-VKZWuLQ (J)Z
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public synthetic fun getEndInclusive ()Ljava/lang/Comparable; public synthetic fun getEndInclusive ()Ljava/lang/Comparable;
public fun getEndInclusive ()Lkotlin/ULong; public fun getEndInclusive ()Lkotlin/ULong;
@@ -4228,20 +4256,20 @@ public final class kotlin/ranges/ULongRange$Companion {
} }
public final class kotlin/ranges/URangesKt { public final class kotlin/ranges/URangesKt {
public static final fun downTo-25l8n7yt (II)Lkotlin/ranges/UIntProgression; public static final fun downTo-5PvTz6A (SS)Lkotlin/ranges/UIntProgression;
public static final fun downTo-2ccbonl2 (BB)Lkotlin/ranges/UIntProgression; public static final fun downTo-J1ME1BU (II)Lkotlin/ranges/UIntProgression;
public static final fun downTo-6o7e3yo2 (JJ)Lkotlin/ranges/ULongProgression; public static final fun downTo-Kr8caGY (BB)Lkotlin/ranges/UIntProgression;
public static final fun downTo-cjsx449s (SS)Lkotlin/ranges/UIntProgression; public static final fun downTo-eb3DHEI (JJ)Lkotlin/ranges/ULongProgression;
public static final fun random (Lkotlin/ranges/UIntRange;Lkotlin/random/Random;)I public static final fun random (Lkotlin/ranges/UIntRange;Lkotlin/random/Random;)I
public static final fun random (Lkotlin/ranges/ULongRange;Lkotlin/random/Random;)J public static final fun random (Lkotlin/ranges/ULongRange;Lkotlin/random/Random;)J
public static final fun reversed (Lkotlin/ranges/UIntProgression;)Lkotlin/ranges/UIntProgression; public static final fun reversed (Lkotlin/ranges/UIntProgression;)Lkotlin/ranges/UIntProgression;
public static final fun reversed (Lkotlin/ranges/ULongProgression;)Lkotlin/ranges/ULongProgression; public static final fun reversed (Lkotlin/ranges/ULongProgression;)Lkotlin/ranges/ULongProgression;
public static final fun step (Lkotlin/ranges/UIntProgression;I)Lkotlin/ranges/UIntProgression; public static final fun step (Lkotlin/ranges/UIntProgression;I)Lkotlin/ranges/UIntProgression;
public static final fun step (Lkotlin/ranges/ULongProgression;J)Lkotlin/ranges/ULongProgression; public static final fun step (Lkotlin/ranges/ULongProgression;J)Lkotlin/ranges/ULongProgression;
public static final fun until-25l8n7yt (II)Lkotlin/ranges/UIntRange; public static final fun until-5PvTz6A (SS)Lkotlin/ranges/UIntRange;
public static final fun until-2ccbonl2 (BB)Lkotlin/ranges/UIntRange; public static final fun until-J1ME1BU (II)Lkotlin/ranges/UIntRange;
public static final fun until-6o7e3yo2 (JJ)Lkotlin/ranges/ULongRange; public static final fun until-Kr8caGY (BB)Lkotlin/ranges/UIntRange;
public static final fun until-cjsx449s (SS)Lkotlin/ranges/UIntRange; public static final fun until-eb3DHEI (JJ)Lkotlin/ranges/ULongRange;
} }
public abstract interface class kotlin/reflect/KAnnotatedElement { public abstract interface class kotlin/reflect/KAnnotatedElement {
@@ -5137,10 +5165,10 @@ public final class kotlin/text/Typography {
} }
public final class kotlin/text/UStringNumberConversionsKt { public final class kotlin/text/UStringNumberConversionsKt {
public static final fun toString-21alb53h (JI)Ljava/lang/String; public static final fun toString-JSWoG40 (JI)Ljava/lang/String;
public static final fun toString-2kxm18v2 (BI)Ljava/lang/String; public static final fun toString-LxnNnR4 (BI)Ljava/lang/String;
public static final fun toString-4t3x8z9q (II)Ljava/lang/String; public static final fun toString-V7xB4Y4 (II)Ljava/lang/String;
public static final fun toString-8wantzby (SI)Ljava/lang/String; public static final fun toString-olVBNx4 (SI)Ljava/lang/String;
public static final fun toUByte (Ljava/lang/String;)B public static final fun toUByte (Ljava/lang/String;)B
public static final fun toUByte (Ljava/lang/String;I)B public static final fun toUByte (Ljava/lang/String;I)B
public static final fun toUByteOrNull (Ljava/lang/String;)Lkotlin/UByte; public static final fun toUByteOrNull (Ljava/lang/String;)Lkotlin/UByte;