Skip to content

Commit

Permalink
Merge pull request #1594 from oyvindberg/enable-derives-for-scala-3
Browse files Browse the repository at this point in the history
Enable support for `derives` in Scala 3 for `Read`, `Write` and `Text`
  • Loading branch information
jatcwang authored Dec 10, 2021
2 parents afe1f26 + e6ecf82 commit aa68012
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/core/src/main/scala-3/util/ReadPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait ReadPlatform:
)

// Generic Read for products.
given [P <: Product, A](
given derived [P <: Product, A](
using m: Mirror.ProductOf[P],
i: A =:= m.MirroredElemTypes,
w: Read[A]
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala-3/util/WritePlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait WritePlatform:
)

// Generic write for products.
given [P <: Product, A](
given derived[P <: Product, A](
using m: Mirror.ProductOf[P],
i: m.MirroredElemTypes =:= A,
w: Write[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ trait ReadSuitePlatform { self: munit.FunSuite =>
util.Read[Option[(Int, Woozle *: Woozle *: String *: EmptyTuple)]]
}

test("derives") {
case class Foo(a: String, b: Int) derives util.Read
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ trait WriteSuitePlatform { self: munit.FunSuite =>
util.Write[Option[(Int, Woozle *: Woozle *: String *: EmptyTuple)]]
}

test("derives") {
case class Foo(a: String, b: Int) derives util.Write
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait TextPlatform { this: Text.type =>
(h product t).contramap(l => (l.head, l.tail))

// Put is available for single-element products.
given [P <: Product, A](
given derived[P <: Product, A](
using m: Mirror.ProductOf[P],
i: m.MirroredElemTypes =:= A,
t: Text[A]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2013-2020 Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package doobie.postgres

trait TextSuitePlatform { self: munit.FunSuite =>

}
11 changes: 11 additions & 0 deletions modules/postgres/src/test/scala-3/postgres/TextSuitePlatform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2013-2020 Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package doobie.postgres

trait TextSuitePlatform { self: munit.FunSuite =>
test("derives") {
case class Foo(a: String, b: Int) derives Text
}
}

0 comments on commit aa68012

Please sign in to comment.