Skip to content
Closed
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
7 changes: 5 additions & 2 deletions arrow-libs/core/arrow-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ plugins {

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
compilerOptions.freeCompilerArgs.add("-Xcontext-parameters")
compilerOptions.freeCompilerArgs.addAll(
"-Xexpect-actual-classes",
"-Xcontext-parameters",
"-Xallow-contracts-on-more-functions"
)

sourceSets {
val nonJvmAndJsMain by creating { dependsOn(nonJvmMain.get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ public sealed class Either<out A, out B> {
*/
public fun isLeft(): Boolean {
contract {
returns(true) implies (this@Either is Left)
returns(false) implies (this@Either is Right)
returns(true) implies (this@Either is Left<A>)
returns(false) implies (this@Either is Right<B>)
}
return this@Either is Left<A>
}
Expand All @@ -501,8 +501,8 @@ public sealed class Either<out A, out B> {
*/
public fun isRight(): Boolean {
contract {
returns(true) implies (this@Either is Right)
returns(false) implies (this@Either is Left)
returns(true) implies (this@Either is Right<B>)
returns(false) implies (this@Either is Left<A>)
}
return this@Either is Right<B>
}
Expand Down Expand Up @@ -530,7 +530,7 @@ public sealed class Either<out A, out B> {
*/
public inline fun isLeft(predicate: (A) -> Boolean): Boolean {
contract {
returns(true) implies (this@Either is Left)
returns(true) implies (this@Either is Left<A>)
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)
}
return this@Either is Left<A> && predicate(value)
Expand Down Expand Up @@ -559,7 +559,7 @@ public sealed class Either<out A, out B> {
*/
public inline fun isRight(predicate: (B) -> Boolean): Boolean {
contract {
returns(true) implies (this@Either is Right)
returns(true) implies (this@Either is Right<B>)
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)
}
return this@Either is Right<B> && predicate(value)
Expand Down Expand Up @@ -725,7 +725,7 @@ public sealed class Either<out A, out B> {
*/
public fun getOrNull(): B? {
contract {
returnsNotNull() implies (this@Either is Right)
returnsNotNull() implies (this@Either is Right<B>)
}
return getOrElse { null }
}
Expand All @@ -747,7 +747,7 @@ public sealed class Either<out A, out B> {
*/
public fun leftOrNull(): A? {
contract {
returnsNotNull() implies (this@Either is Left)
returnsNotNull() implies (this@Either is Left<A>)
}
return fold(::identity) { null }
}
Expand Down
28 changes: 14 additions & 14 deletions arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Ior.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public sealed class Ior<out A, out B> {
*/
public fun isLeft(): Boolean {
contract {
returns(true) implies (this@Ior is Left)
returns(false) implies (this@Ior is Right || this@Ior is Both)
returns(true) implies (this@Ior is Left<A>)
returns(false) implies (this@Ior is Right<B> || this@Ior is Both<A, B>)
}
return this@Ior is Ior.Left<A>
}
Expand All @@ -75,8 +75,8 @@ public sealed class Ior<out A, out B> {
*/
public fun isRight(): Boolean {
contract {
returns(true) implies (this@Ior is Right)
returns(false) implies (this@Ior is Left || this@Ior is Both)
returns(true) implies (this@Ior is Right<B>)
returns(false) implies (this@Ior is Left<A> || this@Ior is Both<A, B>)
}
return this@Ior is Ior.Right<B>
}
Expand All @@ -98,8 +98,8 @@ public sealed class Ior<out A, out B> {
*/
public fun isBoth(): Boolean {
contract {
returns(false) implies (this@Ior is Right || this@Ior is Left)
returns(true) implies (this@Ior is Both)
returns(false) implies (this@Ior is Right<B> || this@Ior is Left<A>)
returns(true) implies (this@Ior is Both<A, B>)
}
return this@Ior is Ior.Both<A, B>
}
Expand Down Expand Up @@ -263,7 +263,7 @@ public sealed class Ior<out A, out B> {

public fun getOrNull(): B? {
contract {
returnsNotNull() implies (this@Ior is Right || this@Ior is Both)
returnsNotNull() implies (this@Ior is Right<B> || this@Ior is Both<A, B>)
}
return fold({ null }, { it }, { _, b -> b })
}
Expand All @@ -289,7 +289,7 @@ public sealed class Ior<out A, out B> {
*/
public fun leftOrNull(): A? {
contract {
returnsNotNull() implies (this@Ior is Left || this@Ior is Both)
returnsNotNull() implies (this@Ior is Left<A> || this@Ior is Both<A, B>)
}
return fold({ it }, { null }, { a, _ -> a })
}
Expand Down Expand Up @@ -335,8 +335,8 @@ public sealed class Ior<out A, out B> {
*/
public inline fun isLeft(predicate: (A) -> Boolean): Boolean {
contract {
returns(true) implies (this@Ior is Left)
returns(false) implies (this@Ior is Right || this@Ior is Both)
returns(true) implies (this@Ior is Left<A>)
returns(false) implies (this@Ior is Right<B> || this@Ior is Both<A, B>)
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)
}
return this@Ior is Left<A> && predicate(value)
Expand All @@ -361,8 +361,8 @@ public sealed class Ior<out A, out B> {
*/
public inline fun isRight(predicate: (B) -> Boolean): Boolean {
contract {
returns(true) implies (this@Ior is Right)
returns(false) implies (this@Ior is Left || this@Ior is Both)
returns(true) implies (this@Ior is Right<B>)
returns(false) implies (this@Ior is Left<A> || this@Ior is Both<A, B>)
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)
}
return this@Ior is Right<B> && predicate(value)
Expand All @@ -388,8 +388,8 @@ public sealed class Ior<out A, out B> {
*/
public inline fun isBoth(leftPredicate: (A) -> Boolean, rightPredicate: (B) -> Boolean): Boolean {
contract {
returns(true) implies (this@Ior is Both)
returns(false) implies (this@Ior is Left || this@Ior is Right)
returns(true) implies (this@Ior is Both<A, B>)
returns(false) implies (this@Ior is Left<A> || this@Ior is Right<B>)
callsInPlace(leftPredicate, InvocationKind.AT_MOST_ONCE)
callsInPlace(rightPredicate, InvocationKind.AT_MOST_ONCE)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public sealed class Option<out A> {
*/
public fun isNone(): Boolean {
contract {
returns(false) implies (this@Option is Some)
returns(false) implies (this@Option is Some<A>)
returns(true) implies (this@Option is None)
}
return this@Option is None
Expand All @@ -394,7 +394,7 @@ public sealed class Option<out A> {
*/
public fun isSome(): Boolean {
contract {
returns(true) implies (this@Option is Some)
returns(true) implies (this@Option is Some<A>)
returns(false) implies (this@Option is None)
}
return this@Option is Some<A>
Expand Down Expand Up @@ -426,7 +426,7 @@ public sealed class Option<out A> {
public inline fun isSome(predicate: (A) -> Boolean): Boolean {
contract {
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)
returns(true) implies (this@Option is Some)
returns(true) implies (this@Option is Some<A>)
}
return this@Option is Some<A> && predicate(value)
}
Expand All @@ -448,7 +448,7 @@ public sealed class Option<out A> {
*/
public fun getOrNull(): A? {
contract {
returnsNotNull() implies (this@Option is Some)
returnsNotNull() implies (this@Option is Some<A>)
}
return getOrElse { null }
}
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/arrow.kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fun KotlinCommonCompilerOptions.commonCompilerOptions() {
apiVersion = KotlinVersion.KOTLIN_2_0
languageVersion = KotlinVersion.KOTLIN_2_0
freeCompilerArgs.addAll(
"-Xdata-flow-based-exhaustiveness",
"-Xreport-all-warnings",
"-Xrender-internal-diagnostic-names",
)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ classgraph = "4.8.181"
dokka = "2.1.0-Beta"
kotest = "6.0.3"
kover = "0.9.1"
kotlin = "2.2.10"
kotlin = "2.2.20"
kotlinCompileTesting = "0.8.0"
knit = "0.5.0"
kspVersion = "2.2.10-2.0.2"
Expand Down
Loading