[play-]slick now comes with Scala 3 artifacts
Hey @nafg,
I am running into problems upgrading to latest slick 3.5.0-M4 with Scala 3 support. Do you mind taking a look yourself if you have time? To reproduce:
git clone [email protected]:mkurz/play-samples.git
cd play-samples
git checkout slick_scala3
cd play-scala-isolated-slick-example
# Set the scala version for the test script:
export MATRIX_SCALA=3.x
# Run the test script:
./scripts/test-sbt
You will see errors:
[error] -- Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:4:22
[error] 4 |object Tables extends {
[error] | ^
[error] | `extends` must be followed by at least one parent
[error] -- [E009] Syntax Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:6:2
[error] 6 |} with Tables
[error] | ^^^^
[error] | Early definitions are not supported; use trait parameters instead
[error] |
[error] | longer explanation available when compiling with `-explain`
[error] -- Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:6:7
[error] 6 |} with Tables
[error] | ^^^^^^
[error] | end of toplevel definition expected but identifier found
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:36:27
[error] 36 | FlywaySchemaHistoryRow.tupled((<<[Int], <<?[String], <<[String], <<[String], <<[String], <<?[Int], <<[String], <<[java.time.Instant], <<[Int], <<[Boolean]))
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |value tupled is not a member of object Tables.this.FlywaySchemaHistoryRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:41:153
[error] 41 | def * = (installedRank, version, description, `type`, script, checksum, installedBy, installedOn, executionTime, success) <> (FlywaySchemaHistoryRow.tupled, FlywaySchemaHistoryRow.unapply)
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |value tupled is not a member of object Tables.this.FlywaySchemaHistoryRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:43:268
[error] 43 | def ? = ((Rep.Some(installedRank), version, Rep.Some(description), Rep.Some(`type`), Rep.Some(script), checksum, Rep.Some(installedBy), Rep.Some(installedOn), Rep.Some(executionTime), Rep.Some(success))).shaped.<>({r=>import r._; _1.map(_=> FlywaySchemaHistoryRow.tupled((_1.get, _2, _3.get, _4.get, _5.get, _6, _7.get, _8.get, _9.get, _10.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported."))
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |value tupled is not a member of object Tables.this.FlywaySchemaHistoryRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:82:13
[error] 82 | UsersRow.tupled((<<[String], <<[String], <<[java.time.Instant], <<?[java.time.Instant]))
[error] | ^^^^^^^^^^^^^^^
[error] | value tupled is not a member of object Tables.this.UsersRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:86:59
[error] 86 | def * = (id, email, createdAt, updatedAt) <> (UsersRow.tupled, UsersRow.unapply)
[error] | ^^^^^^^^^^^^^^^
[error] | value tupled is not a member of object Tables.this.UsersRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:88:124
[error] 88 | def ? = ((Rep.Some(id), Rep.Some(email), Rep.Some(createdAt), updatedAt)).shaped.<>({r=>import r._; _1.map(_=> UsersRow.tupled((_1.get, _2.get, _3.get, _4)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported."))
[error] | ^^^^^^^^^^^^^^^
[error] | value tupled is not a member of object Tables.this.UsersRow
[warn] two warnings found
[error] 9 errors found
Also the play-scala-slick-example example is failing if you run it with Scala 3 with the ./scripts/test-sbt script.
Your issue is that while the application is built against 3.5.0-M4, that's not the code generator you're using. Instead, your sbt built uses https://github.com/tototoshi/sbt-slick-codegen which is built for Slick 3.3.3.
I tried overriding the transitive dependency in the SBT build and got a NoSuchMethodError. So that plugin needs to be built against an updated Slick version.
Finally, this works. Scala 3 required the usual adjustments, however 5318222a92ff096556f41137ef4c5a47aa368940 required a bit more attention. Companies nested inside the CompaniesComponent trait didn't work well, so I just removed it since I couldn't see a real benefit. Very likely the problem is caused because of https://docs.scala-lang.org/scala3/reference/dropped-features/type-projection.html which we hit in play-silhouette already (starting conversation here: https://github.com/playframework/play-silhouette/pull/36#issuecomment-1821156181)
@Mergifyio backport 3.0.x
backport 3.0.x
✅ Backports have been created
- #550 [3.0.x] [play-]slick now comes with Scala 3 artifacts (backport #368) by @mkurz has been created for branch
3.0.xbut encountered conflicts