Skip to content
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

Support Scala3 #474

Merged
merged 10 commits into from
Aug 27, 2022
Merged

Support Scala3 #474

merged 10 commits into from
Aug 27, 2022

Conversation

cchantep
Copy link
Member

No description provided.

@cchantep cchantep force-pushed the task/dotty branch 14 times, most recently from 25f953a to 2b83f43 Compare August 17, 2022 21:48

private[anorm] trait PackageCompat:

extension (query: SqlQuery)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More Scala2 implicit conversion that previously pimps SqlQuery as SimpleSql[Row] with extended combinators

@@ -57,12 +57,8 @@ private[anorm] object SealedRowParserImpl {
val caseName = TermName(c.freshName("discriminated"))
val key = q"$discriminate(${subclass.typeSymbol.fullName})"
val caseDecl = q"val $caseName = $key"
val subtype = {
if (subclass.typeSymbol.asClass.typeParams.isEmpty) subclass
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic subclass is not supported anyway (error raised therebefore)

@@ -0,0 +1,3 @@
package com.github.ghik.silencer

class silent(s: String = "") extends scala.annotation.StaticAnnotation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compatibility workaround

@@ -262,7 +277,6 @@ object Sql { // TODO: Rename to SQL
private def toSql(ts: List[StatementToken], buf: StringBuilder): StringBuilder = ts.foldLeft(buf) {
case (sql, StringToken(t)) => sql ++= t
case (sql, PercentToken) => sql += '%'
case (sql, _) => sql
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable

@@ -0,0 +1,104 @@
package anorm

private[anorm] trait MacroOptions {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common to both versions

@@ -0,0 +1,180 @@
package anorm

trait RowParser[+A] extends (Row => SqlResult[A]) { parent =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted from SqlParser.scala

@@ -567,185 +567,6 @@ sealed trait DeprecatedSqlParser { _: SqlParser.type =>
@SuppressWarnings(Array("ClassNames"))
final case class ~[+A, +B](_1: A, _2: B)

object RowParser {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved as separate file

@cchantep cchantep force-pushed the task/dotty branch 3 times, most recently from 22d381a to d8922c0 Compare August 18, 2022 09:33
import scala.language.experimental.macros
import scala.reflect.macros.whitebox

/** Only for internal purposes */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved down or extracted to common MacroOptions trait

@cchantep cchantep force-pushed the task/dotty branch 5 times, most recently from 1c0fbec to c3bb316 Compare August 19, 2022 11:51
@cchantep cchantep force-pushed the task/dotty branch 7 times, most recently from cfe9d74 to 514c03c Compare August 22, 2022 20:46

// Not enough column names for class parameters
shapeless.test.illTyped("""anorm.Macro.parser[Foo[Int]]("Foo", "Bar")""")
"not be resolved" in {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve compile-time tests

@@ -263,8 +325,23 @@ lazy val `anorm-postgres` = (project in file("postgres"))

lazy val `anorm-enumeratum` = (project in file("enumeratum"))
.settings(
sourceDirectory := {
if (scalaBinaryVersion.value == "3") new java.io.File("/no/sources")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enumeratum not released to Scala 3

@@ -14,6 +14,20 @@ sealed trait SqlResult[+A] { self =>
case e @ Error(_) => e
}

def collect[B](f: PartialFunction[A, B]): SqlResult[B] = self match {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New combinator

@cchantep cchantep marked this pull request as ready for review August 22, 2022 20:56
@cchantep cchantep changed the title WIP: Support Scala3 Support Scala3 Aug 22, 2022
@cchantep cchantep merged commit 3f1f8e4 into playframework:main Aug 27, 2022
@cchantep cchantep deleted the task/dotty branch August 27, 2022 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant