Skip to content

Commit

Permalink
Enable experimental K2 (#3087)
Browse files Browse the repository at this point in the history
* Update all dependencies

| datasource | package                                                                                           | from          | to           |
| ---------- | ------------------------------------------------------------------------------------------------- | ------------- | ------------ |
| maven      | com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin                                     | 1.8.22-1.0.11 | 1.9.0-1.0.11 |
| maven      | com.google.devtools.ksp:symbol-processing-api                                                     | 1.8.22-1.0.11 | 1.9.0-1.0.11 |
| maven      | org.jetbrains.kotlin.plugin.serialization:org.jetbrains.kotlin.plugin.serialization.gradle.plugin | 1.8.22        | 1.9.0        |
| maven      | org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin               | 1.8.22        | 1.9.0        |
| maven      | org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin                                   | 1.8.22        | 1.9.0        |

* Update API files

* Retrigger CI

* Upgrade yarn.lock

* Remove wrong versions in yarn.lock

* kotlin.mpp.enableCompatibilityMetadataVariant is deprecated

* Update yarn.lock in Action

* Temporarily disable tests

* Enable experimental K2

* Switch to 1.9.20-dev version

* Messages in @deprecated must be @PublishedApi

* API dump

* Fix some problems visible in K2

* Update API files

* Run K2 into its own workflow job

* Use dev version only in K2

* Try flaky race test 10 times

* Update Kotlin dev version

* Update Kotlin dev version

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <renovate[bot]@users.noreply.github.com>
Co-authored-by: Simon Vergauwen <[email protected]>
Co-authored-by: serras <[email protected]>
  • Loading branch information
5 people authored Aug 25, 2023
1 parent 9b41cba commit 50216fa
Show file tree
Hide file tree
Showing 37 changed files with 197 additions and 262 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,36 @@ jobs:
name: 'reports-jvmTest'
path: '**/build/reports/**'

jvmTestK2:
runs-on: ubuntu-latest
timeout-minutes: 60

env:
KOTLIN_OVERRIDE: 1.9.30-dev-1098

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11

- name: jvmTest (K2 enabled)
uses: gradle/gradle-build-action@v2
with:
arguments: jvmTest -Pkotlin.experimental.tryK2=true

- name: Upload reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: 'reports-jvmTest'
path: '**/build/reports/**'

js:
runs-on: ubuntu-latest
timeout-minutes: 60
Expand Down
15 changes: 8 additions & 7 deletions arrow-libs/core/arrow-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id(libs.plugins.kotlin.multiplatform.get().pluginId)
alias(libs.plugins.arrowGradleConfig.kotlin)
alias(libs.plugins.arrowGradleConfig.publish)

alias(libs.plugins.spotless)
}

Expand Down Expand Up @@ -37,12 +36,14 @@ kotlin {
}
}
}
}

apply(from = property("ANIMALSNIFFER_MPP"))

tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.annotations"
jvm {
tasks.jvmJar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.annotations"
}
}
}
}

apply(from = property("ANIMALSNIFFER_MPP"))
11 changes: 6 additions & 5 deletions arrow-libs/core/arrow-atomic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ kotlin {
runtimeOnly(libs.kotest.runnerJUnit5)
}
}

}
}

tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.atomic"
jvm {
tasks.jvmJar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.atomic"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class arrow/continuations/generic/ControlThrowable : java/lang/Throwable
public fun fillInStackTrace ()Ljava/lang/Throwable;
}

public final class arrow/continuations/generic/ControlThrowableKt {
public static final field deprecateArrowContinuation Ljava/lang/String;
}

public abstract interface class arrow/continuations/generic/DelimitedContinuation {
public abstract fun invoke (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
Expand Down
10 changes: 6 additions & 4 deletions arrow-libs/core/arrow-continuations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ kotlin {
}
}
}
}

tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.continuations"
jvm {
tasks.jvmJar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.continuations"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ package arrow.continuations.generic
@Deprecated(deprecateArrowContinuation)
public expect open class ControlThrowable() : Throwable

internal const val deprecateArrowContinuation: String =
@PublishedApi internal const val deprecateArrowContinuation: String =
"arrow.continuation is being discontinued and will be removed in the next version in favor of the Effect/ EagerEffect Runtime. If you depend on low-level APIs as in arrow.continuation, feel free to write us in the Kotlin Slack channel for guidance."
5 changes: 5 additions & 0 deletions arrow-libs/core/arrow-core-retrofit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ dependencies {
testImplementation(libs.squareup.retrofitConverterMoshi)
testImplementation(libs.kotlinx.serializationJson)
testImplementation(libs.jakewharton.retrofitConverterKotlinxSerialization)
}

tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.core.retrofit"
}
}
8 changes: 8 additions & 0 deletions arrow-libs/core/arrow-core-serialization/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ kotlin {
}
}
}

jvm {
tasks.jvmJar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.core.serialization"
}
}
}
}
21 changes: 21 additions & 0 deletions arrow-libs/core/arrow-core/api/arrow-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,7 @@ public final class arrow/core/PredefKt {
}

public final class arrow/core/ResultKt {
public static final field deprecateZip Ljava/lang/String;
public static final fun composeErrors ([Ljava/lang/Throwable;)Ljava/lang/Throwable;
public static final fun flatMap (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun getUnitResult ()Ljava/lang/Object;
Expand Down Expand Up @@ -2598,6 +2599,8 @@ public final class arrow/core/Validated$Valid$Companion {
}

public final class arrow/core/ValidatedKt {
public static final field DeprAndNicheMsg Ljava/lang/String;
public static final field ValidatedDeprMsg Ljava/lang/String;
public static final fun andThen (Larrow/core/Validated;Lkotlin/jvm/functions/Function1;)Larrow/core/Validated;
public static final fun attempt (Larrow/core/Validated;)Larrow/core/Validated;
public static final fun bisequence (Larrow/core/Validated;)Ljava/util/List;
Expand Down Expand Up @@ -2671,6 +2674,7 @@ public final class arrow/core/computations/EitherEffect$DefaultImpls {
}

public final class arrow/core/computations/EitherKt {
public static final field eitherDSLDeprecation Ljava/lang/String;
public static final fun ensureNotNull (Larrow/core/computations/EitherEffect;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand All @@ -2695,6 +2699,7 @@ public final class arrow/core/computations/NullableEffect$DefaultImpls {
}

public final class arrow/core/computations/NullableKt {
public static final field nullableDSLDeprecation Ljava/lang/String;
public static final fun ensureNotNull (Larrow/core/computations/NullableEffect;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand All @@ -2709,6 +2714,7 @@ public final class arrow/core/computations/OptionEffect$DefaultImpls {
}

public final class arrow/core/computations/OptionKt {
public static final field optionDSLDeprecation Ljava/lang/String;
public static final fun ensureNotNull (Larrow/core/computations/OptionEffect;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

Expand Down Expand Up @@ -2753,6 +2759,10 @@ public final class arrow/core/computations/ResultEffect {
public final fun bind (Ljava/lang/Object;)Ljava/lang/Object;
}

public final class arrow/core/computations/ResultKt {
public static final field resultDSLDeprecation Ljava/lang/String;
}

public final class arrow/core/computations/either {
public static final field INSTANCE Larrow/core/computations/either;
public final fun eager (Lkotlin/jvm/functions/Function2;)Larrow/core/Either;
Expand Down Expand Up @@ -2938,6 +2948,10 @@ public final class arrow/core/continuations/EffectScopeKt {
public static final fun ensureNotNull (Larrow/core/continuations/EffectScope;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class arrow/core/continuations/EitherKt {
public static final field eitherDSLDeprecation Ljava/lang/String;
}

public final class arrow/core/continuations/FoldContinuation : arrow/core/continuations/Token, arrow/core/continuations/EffectScope, kotlin/coroutines/Continuation {
public field recover Lkotlin/jvm/functions/Function2;
public fun <init> (Larrow/core/continuations/Token;Lkotlin/coroutines/CoroutineContext;Lkotlin/coroutines/Continuation;)V
Expand Down Expand Up @@ -3007,6 +3021,10 @@ public final class arrow/core/continuations/IorEffectScope : arrow/core/continua
public fun shift (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class arrow/core/continuations/IorKt {
public static final field iorDSLDeprecation Ljava/lang/String;
}

public final class arrow/core/continuations/NullableEagerEffectScope : arrow/core/continuations/EagerEffectScope {
public fun attempt (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static fun attempt-impl (Larrow/core/continuations/EagerEffectScope;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -3088,6 +3106,7 @@ public final class arrow/core/continuations/NullableEffectScope : arrow/core/con
}

public final class arrow/core/continuations/NullableKt {
public static final field nullableDSLDeprecation Ljava/lang/String;
public static final fun ensureNotNull-0Rsnnio (Larrow/core/continuations/EffectScope;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun ensureNotNull-7s8y1X8 (Larrow/core/continuations/EagerEffectScope;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
Expand Down Expand Up @@ -3171,6 +3190,7 @@ public final class arrow/core/continuations/OptionEffectScope : arrow/core/conti
}

public final class arrow/core/continuations/OptionKt {
public static final field optionDSLDeprecation Ljava/lang/String;
public static final fun ensureNotNull-09sQPHg (Larrow/core/continuations/EffectScope;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun ensureNotNull-dxZa7OQ (Larrow/core/continuations/EagerEffectScope;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun toOption (Larrow/core/continuations/EagerEffect;)Larrow/core/Option;
Expand Down Expand Up @@ -3254,6 +3274,7 @@ public final class arrow/core/continuations/ResultEffectScope : arrow/core/conti
}

public final class arrow/core/continuations/ResultKt {
public static final field resultDSLDeprecation Ljava/lang/String;
public static final fun toResult (Larrow/core/continuations/EagerEffect;)Ljava/lang/Object;
public static final fun toResult (Larrow/core/continuations/Effect;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
Expand Down
14 changes: 8 additions & 6 deletions arrow-libs/core/arrow-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ kotlin {
}
}
}

jvm {
tasks.jvmJar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.core"
}
}
}
}

// enables context receivers for Jvm Tests
tasks.named<KotlinCompile>("compileTestKotlinJvm") {
kotlinOptions.freeCompilerArgs += "-Xcontext-receivers"
}

tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = "arrow.core"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public sealed class Ior<out A, out B> {
public fun isLeft(): Boolean {
contract {
returns(true) implies (this@Ior is Ior.Left<A>)
returns(false) implies (this@Ior is Ior.Right<B>)
returns(false) implies (this@Ior is Ior.Both<A, B>)
returns(false) implies (this@Ior is Ior.Right<B> || this@Ior is Ior.Both<A, B>)
}
return this@Ior is Ior.Left<A>
}
Expand All @@ -127,8 +126,7 @@ public sealed class Ior<out A, out B> {
public fun isRight(): Boolean {
contract {
returns(true) implies (this@Ior is Ior.Right<B>)
returns(false) implies (this@Ior is Ior.Left<A>)
returns(false) implies (this@Ior is Ior.Both<A, B>)
returns(false) implies (this@Ior is Ior.Left<A> || this@Ior is Ior.Both<A, B>)
}
return this@Ior is Ior.Right<B>
}
Expand All @@ -137,8 +135,7 @@ public sealed class Ior<out A, out B> {
@JvmName("_isBoth")
public fun isBoth(): Boolean {
contract {
returns(false) implies (this@Ior is Ior.Right<B>)
returns(false) implies (this@Ior is Ior.Left<A>)
returns(false) implies (this@Ior is Ior.Right<B> || this@Ior is Ior.Left<A>)
returns(true) implies (this@Ior is Ior.Both<A, B>)
}
return this@Ior is Ior.Both<A, B>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract

internal const val deprecateZip: String =
@PublishedApi internal const val deprecateZip: String =
"Prefer using the inline result DSL + bind(). Please, be aware that all the errors are no longer accumulated, just the first error found is considered." +
"In case you think this behaviour should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,8 @@ public inline fun <A> A.validNel(): ValidatedNel<Nothing, A> =
public inline fun <E> E.invalidNel(): ValidatedNel<E, Nothing> =
Validated.invalidNel(this)

internal const val ValidatedDeprMsg = "Validated functionality is being merged into Either.\n"
@PublishedApi internal const val ValidatedDeprMsg: String =
"Validated functionality is being merged into Either.\n"

private const val DeprAndNicheMsg =
@PublishedApi internal const val DeprAndNicheMsg: String =
"Validated functionality is being merged into Either, but this API is niche and will be removed in the future. If this method is crucial for you, please let us know on the Arrow Github. Thanks!\n https://github.com/arrow-kt/arrow/issues\n"
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ public object either {
Effect.suspended(eff = { EitherEffect { it } }, f = c, just = { it.right() })
}

private const val eitherDSLDeprecation =
@PublishedApi internal const val eitherDSLDeprecation: String =
"The either DSL has been moved to arrow.core.raise.either.\n" +
"Replace import arrow.core.computations.* with arrow.core.raise.*"
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ public object nullable {
Effect.suspended(eff = { NullableEffect { it } }, f = func, just = { it })
}

private const val nullableDSLDeprecation =
@PublishedApi internal const val nullableDSLDeprecation: String =
"The nullable DSL has been moved to arrow.core.raise.nullable.\n" +
"Replace import arrow.core.computations.* with arrow.core.raise.*"
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ public object option {
Effect.suspended(eff = { OptionEffect { it } }, f = func, just = { Option.fromNullable(it) })
}

private const val optionDSLDeprecation =
@PublishedApi internal const val optionDSLDeprecation: String =
"The option DSL has been moved to arrow.core.raise.option.\n" +
"Replace import arrow.core.computations.* with arrow.core.raise.*"
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public object result {
kotlin.runCatching { block(ResultEffect) }
}

private const val resultDSLDeprecation =
@PublishedApi internal const val resultDSLDeprecation: String =
"The result DSL has been moved to arrow.core.raise.result.\n" +
"Replace import arrow.core.computations.* with arrow.core.raise.*"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public object either {
effect(f).toEither()
}

private const val eitherDSLDeprecation =
@PublishedApi internal const val eitherDSLDeprecation: String =
"The either DSL has been moved to arrow.core.raise.either.\n" +
"Replace import arrow.core.computations.either with arrow.core.raise.either"
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public class IorEagerEffectScope<E>(semigroup: Semigroup<E>, private val effect:
override suspend fun <B> shift(r: E): B = effect.shift(combine(r))
}

private const val iorDSLDeprecation =
@PublishedApi internal const val iorDSLDeprecation: String =
"The ior DSL has been moved to arrow.core.raise.ior.\n" +
"Replace import arrow.core.computations.ior with arrow.core.raise.ior"
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ public object nullable {
effect<Nothing?, A> { f(NullableEffectScope(this)) }.orNull()
}

private const val nullableDSLDeprecation =
@PublishedApi internal const val nullableDSLDeprecation: String =
"The nullable DSL has been moved to arrow.core.raise.nullable.\n" +
"Replace import arrow.core.computations.nullable with arrow.core.raise.nullable"
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ public object option {
effect<None, A> { f(OptionEffectScope(this)) }.toOption()
}

private const val optionDSLDeprecation =
@PublishedApi internal const val optionDSLDeprecation: String =
"The option DSL has been moved to arrow.core.raise.option.\n" +
"Replace import arrow.core.computations.option with arrow.core.raise.option"
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public object result {
effect<Throwable, A> { f(ResultEffectScope(this)) }.toResult()
}

private const val resultDSLDeprecation =
@PublishedApi internal const val resultDSLDeprecation: String =
"The result DSL has been moved to arrow.core.raise.result.\n" +
"Replace import arrow.core.computations.* with arrow.core.raise.*"
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ public final class arrow/fx/coroutines/ResourceExtensionsKt {
}

public final class arrow/fx/coroutines/ResourceKt {
public static final field nextVersionRemoved Ljava/lang/String;
public static final fun asFlow (Larrow/fx/coroutines/Resource;)Lkotlinx/coroutines/flow/Flow;
public static final fun release (Larrow/fx/coroutines/Resource;Lkotlin/jvm/functions/Function2;)Larrow/fx/coroutines/Resource;
public static final fun release-zgiIeyo (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Larrow/fx/coroutines/Resource;
Expand Down
Loading

0 comments on commit 50216fa

Please sign in to comment.