Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class Bijection<A, B>(val underlying: dev.typr.foundations.Bijection<A, B>) {
fun inverse(): Bijection<B, A> = Bijection(underlying.inverse())

companion object {
fun <A, B> of(forward: (A) -> B, backward: (B) -> A): Bijection<A, B> =
Bijection(dev.typr.foundations.Bijection.of(forward, backward))

internal fun <T> optionalToNullable(): dev.typr.foundations.Bijection<Optional<T>, T?> =
dev.typr.foundations.Bijection.optionalToNullable<T>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open class ConnectionRead(val underlying: dev.typr.foundations.ConnectionRead) {

class Connection(private val java: dev.typr.foundations.Connection) : ConnectionRead(java) {

internal val javaConnection: dev.typr.foundations.Connection get() = java
val javaConnection: dev.typr.foundations.Connection get() = java

fun <T> execute(op: Operation<T>): T =
java.execute(op.underlying)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@ public sealed interface OperationRead<Out> extends Operation<Out>
OperationRead.Then,
OperationRead.Configured {

/** Run this read operation on the given read connection. */
/** Run this read operation on a read-only connection. */
default Out run(ConnectionRead conn) {
return conn.execute(this);
}

/**
* Re-declares the inherited {@link Operation#run(Connection)} on this trait so Scala 3's
* overload resolver sees both {@code run(Connection)} and {@code run(ConnectionRead)} declared
* at the same level — then specificity ({@code Connection <: ConnectionRead}) picks the more
* specific overload for {@code c: Connection} call sites without ambiguity. Java and Kotlin
* always picked the most-specific overload regardless; this redeclaration is purely for the
* Scala 3 overload resolver. Pure delegation; same body as the inherited default.
*/
@Override
default Out run(Connection conn) {
return conn.execute(this);
}

/**
* Execute this operation using the given transactor.
*
Expand Down
Loading