Skip to content

Convert return in expression body to labeled return in preparation for KT-22786 #4460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: kotlin-community/k2/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @tbogdanova @woainikk
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/CacheRedirector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.gradle.api.artifacts.repositories.*
import org.gradle.api.initialization.dsl.*
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.targets.js.nodejs.*
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.*
import org.jetbrains.kotlin.gradle.targets.js.yarn.*
import java.net.*

Expand Down Expand Up @@ -100,6 +99,7 @@ private fun Project.checkRedirect(repositories: RepositoryHandler, containerName
}
}

@Suppress("DEPRECATION", "DEPRECATION_ERROR") // KT-68597, KT-68597
private fun Project.configureYarnAndNodeRedirects() {
if (CacheRedirector.isEnabled) {
val yarnRootExtension = extensions.findByType<YarnRootExtension>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ kotlin {
watchosDeviceArm64()
}
js {
@Suppress("DEPRECATION", "DEPRECATION_ERROR") // KT-68597, KT-68597
moduleName = project.name
nodejs()
compilations["main"]?.dependencies {
Expand All @@ -57,6 +58,7 @@ kotlin {
wasmJs {
// Module name should be different from the one from JS
// otherwise IC tasks that start clashing different modules with the same module name
@Suppress("DEPRECATION", "DEPRECATION_ERROR") // KT-68597, KT-68597
moduleName = project.name + "Wasm"
nodejs()
compilations["main"]?.dependencies {
Expand Down
3 changes: 3 additions & 0 deletions integration-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ buildscript {
if (usingSnapshotVersion) {
repositories {
mavenLocal()
maven("https://redirector.kotlinlang.org/maven/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
}
}
Expand All @@ -58,9 +59,11 @@ plugins {

repositories {
if (extra["using_snapshot_version"] == true) {
maven("https://redirector.kotlinlang.org/maven/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
}
mavenLocal()
maven("https://redirector.kotlinlang.org/maven/dev")
mavenCentral()
}

Expand Down
1 change: 1 addition & 0 deletions integration-testing/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ junit5_version=5.7.0

kotlin.code.style=official
kotlin.mpp.stability.nowarn=true
org.gradle.jvmargs=-Xmx4096M
1 change: 1 addition & 0 deletions integration-testing/java8Test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
maven("https://redirector.kotlinlang.org/maven/dev")
// Coroutines from the outer project are published by previous CI buils step
mavenLocal()
}
Expand Down
1 change: 1 addition & 0 deletions integration-testing/jpmsTest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ val coroutines_version: String by project
repositories {
if (project.properties["build_snapshot_train"]?.toString()?.toBoolean() == true) {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
maven("https://redirector.kotlinlang.org/maven/dev")
}
mavenLocal()
mavenCentral()
Expand Down
1 change: 1 addition & 0 deletions integration-testing/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pluginManagement {
mavenCentral()
maven("https://plugins.gradle.org/m2/")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
maven("https://redirector.kotlinlang.org/maven/dev")
mavenLocal()
}
}
Expand Down
9 changes: 1 addition & 8 deletions integration-testing/smokeTest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
maven("https://redirector.kotlinlang.org/maven/dev")
// Coroutines from the outer project are published by previous CI builds step
mavenLocal()
}
Expand Down Expand Up @@ -79,11 +80,3 @@ kotlin {
}
}
}

// Drop this configuration when the Node.JS version in KGP will support wasm gc milestone 4
// check it here:
// https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt
rootProject.extensions.findByType(NodeJsRootExtension::class.java)?.apply {
nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}
13 changes: 13 additions & 0 deletions kotlinx-coroutines-core/api/kotlinx-coroutines-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -742,12 +742,25 @@ public final class kotlinx/coroutines/channels/ChannelResult {
public final synthetic fun unbox-impl ()Ljava/lang/Object;
}

public final class kotlinx/coroutines/channels/ChannelResult$Closed : kotlinx/coroutines/channels/ChannelResult$Failed {
public final field cause Ljava/lang/Throwable;
public fun <init> (Ljava/lang/Throwable;)V
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class kotlinx/coroutines/channels/ChannelResult$Companion {
public final fun closed-JP2dKIU (Ljava/lang/Throwable;)Ljava/lang/Object;
public final fun failure-PtdJZtk ()Ljava/lang/Object;
public final fun success-JP2dKIU (Ljava/lang/Object;)Ljava/lang/Object;
}

public class kotlinx/coroutines/channels/ChannelResult$Failed {
public fun <init> ()V
public fun toString ()Ljava/lang/String;
}

public final class kotlinx/coroutines/channels/ChannelsKt {
public static final synthetic fun any (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun cancelConsumed (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/lang/Throwable;)V
Expand Down
17 changes: 17 additions & 0 deletions kotlinx-coroutines-core/api/kotlinx-coroutines-core.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,23 @@ final value class <#A: out kotlin/Any?> kotlinx.coroutines.channels/ChannelResul
final fun hashCode(): kotlin/Int // kotlinx.coroutines.channels/ChannelResult.hashCode|hashCode(){}[0]
final fun toString(): kotlin/String // kotlinx.coroutines.channels/ChannelResult.toString|toString(){}[0]

final class Closed : kotlinx.coroutines.channels/ChannelResult.Failed { // kotlinx.coroutines.channels/ChannelResult.Closed|null[0]
constructor <init>(kotlin/Throwable?) // kotlinx.coroutines.channels/ChannelResult.Closed.<init>|<init>(kotlin.Throwable?){}[0]

final val cause // kotlinx.coroutines.channels/ChannelResult.Closed.cause|{}cause[0]
final fun <get-cause>(): kotlin/Throwable? // kotlinx.coroutines.channels/ChannelResult.Closed.cause.<get-cause>|<get-cause>(){}[0]

final fun equals(kotlin/Any?): kotlin/Boolean // kotlinx.coroutines.channels/ChannelResult.Closed.equals|equals(kotlin.Any?){}[0]
final fun hashCode(): kotlin/Int // kotlinx.coroutines.channels/ChannelResult.Closed.hashCode|hashCode(){}[0]
final fun toString(): kotlin/String // kotlinx.coroutines.channels/ChannelResult.Closed.toString|toString(){}[0]
}

open class Failed { // kotlinx.coroutines.channels/ChannelResult.Failed|null[0]
constructor <init>() // kotlinx.coroutines.channels/ChannelResult.Failed.<init>|<init>(){}[0]

open fun toString(): kotlin/String // kotlinx.coroutines.channels/ChannelResult.Failed.toString|toString(){}[0]
}

final object Companion { // kotlinx.coroutines.channels/ChannelResult.Companion|null[0]
final fun <#A2: kotlin/Any?> closed(kotlin/Throwable?): kotlinx.coroutines.channels/ChannelResult<#A2> // kotlinx.coroutines.channels/ChannelResult.Companion.closed|closed(kotlin.Throwable?){0§<kotlin.Any?>}[0]
final fun <#A2: kotlin/Any?> failure(): kotlinx.coroutines.channels/ChannelResult<#A2> // kotlinx.coroutines.channels/ChannelResult.Companion.failure|failure(){0§<kotlin.Any?>}[0]
Expand Down
2 changes: 2 additions & 0 deletions kotlinx-coroutines-core/common/src/channels/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -939,10 +939,12 @@ public value class ChannelResult<out T>
*/
public fun exceptionOrNull(): Throwable? = (holder as? Closed)?.cause

@PublishedApi
internal open class Failed {
override fun toString(): String = "Failed"
}

@PublishedApi
internal class Closed(@JvmField val cause: Throwable?): Failed() {
override fun equals(other: Any?): Boolean = other is Closed && cause == other.cause
override fun hashCode(): Int = cause.hashCode()
Expand Down
4 changes: 2 additions & 2 deletions kotlinx-coroutines-core/common/src/flow/SharedFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ internal open class SharedFlowImpl<T>(
}

private fun cancelEmitter(emitter: Emitter) = synchronized(this) {
if (emitter.index < head) return // already skipped past this index
if (emitter.index < head) return@synchronized // already skipped past this index
val buffer = buffer!!
if (buffer.getBufferAt(emitter.index) !== emitter) return // already resumed
if (buffer.getBufferAt(emitter.index) !== emitter) return@synchronized // already resumed
buffer.setBufferAt(emitter.index, NO_VALUE)
cleanupTailLocked()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ internal fun restoreThreadContext(context: CoroutineContext, oldState: Any?) {
@PublishedApi
internal data class ThreadLocalKey(private val threadLocal: ThreadLocal<*>) : CoroutineContext.Key<ThreadLocalElement<*>>

@PublishedApi
internal class ThreadLocalElement<T>(
private val value: T,
private val threadLocal: ThreadLocal<T>
Expand Down
33 changes: 16 additions & 17 deletions kotlinx-coroutines-test/api/kotlinx-coroutines-test.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,6 @@ final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = .
// Targets: [native, wasmWasi]
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = ..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]

// Targets: [js, wasmJs]
final class kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting { // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting|null[0]
constructor <init>() // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.<init>|<init>(){}[0]

// Targets: [js]
final fun then(kotlin/Function1<kotlin/Unit, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.Unit,kotlin.Unit>){}[0]

// Targets: [js]
final fun then(kotlin/Function1<kotlin/Unit, kotlin/Unit>, kotlin/Function1<kotlin/Throwable, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.Unit,kotlin.Unit>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>){}[0]

// Targets: [wasmJs]
final fun then(kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>){}[0]

// Targets: [wasmJs]
final fun then(kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>, kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>;kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>){}[0]
}

// Targets: [js, wasmJs]
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin.time/Duration = ..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTest|runTest@kotlinx.coroutines.test.TestScope(kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]

Expand All @@ -105,3 +88,19 @@ final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = .

// Targets: [js, wasmJs]
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = ..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]

// Targets: [js]
final class kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting { // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting|null[0]
constructor <init>() // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.<init>|<init>(){}[0]

final fun then(kotlin/Function1<kotlin/Unit, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.Unit,kotlin.Unit>){}[0]
final fun then(kotlin/Function1<kotlin/Unit, kotlin/Unit>, kotlin/Function1<kotlin/Throwable, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.Unit,kotlin.Unit>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>){}[0]
}

// Targets: [wasmJs]
final class kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting : kotlin.js/JsAny { // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting|null[0]
constructor <init>() // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.<init>|<init>(){}[0]

final fun then(kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>){}[0]
final fun then(kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>, kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>;kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>){}[0]
}
1 change: 0 additions & 1 deletion kotlinx-coroutines-test/wasmJs/src/TestBuilders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import kotlin.js.*

public actual typealias TestResult = JsPromiseInterfaceForTesting

@Suppress("INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION")
internal actual fun createTestResult(testProcedure: suspend CoroutineScope.() -> Unit): TestResult =
GlobalScope.promise {
testProcedure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ a parametric class. So, we make a non-parametric class just for this. */
* @suppress
*/
@JsName("Promise")
public external class JsPromiseInterfaceForTesting {
public external class JsPromiseInterfaceForTesting : JsAny {
/**
* @suppress
*/
Expand Down