-
Notifications
You must be signed in to change notification settings - Fork 26
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
Scala 3 #143
Conversation
val q = parseSelections(sels, None, fragments) | ||
val vs = vds.map { | ||
case VariableDefinition(nme, tpe, _) => UntypedVarDef(nme.value, tpe, None) | ||
def parseOperation(op: Operation, fragments: Map[String, FragmentDefinition]): Result[UntypedOperation] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala 3 warns that this single-case match would only fail with case null =>
so I collapsed it to a destructuring assignment. There are a few more of these.
import io.circe.Json | ||
import io.circe.JsonObject | ||
|
||
object JsonExtractor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because circe-optics doesn't exist for Scala 3 [yet].
@@ -21,7 +21,7 @@ import QueryInterpreter.mkErrorResult | |||
* we need to be able to construct where clauses from predicates over fields/attributes), so | |||
* these cannot be arbitrary functions `Cursor => Boolean`. | |||
*/ | |||
trait Term[T] extends Product with Serializable { | |||
trait Term[T] extends Product with Serializable { // fun fact: making this covariant crashes Scala 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Term[+T]
crashes Scala 3 there are some upcasts to Term[Any]
later on.
c.flatListPath(path).map(_.map { case ScalarFocus(f: T @unchecked) => f }) | ||
c.flatListPath(path).map(_.map { | ||
case ScalarFocus(f: T @unchecked) => f | ||
case _ => sys.error("impossible") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exhaustiveness checker is a lot better so I needed to add a few of these. All these cases should be impossible but maybe the error messages could be better. What do you think?
@@ -170,7 +170,7 @@ class QueryInterpreter[F[_]](mapping: Mapping[F]) { | |||
case Ior.Right(elem) => (errors, elem :: elems) | |||
case Ior.Both(errs, elem) => (errs.toChain ++ errors, elem :: elems) | |||
} | |||
}).map(_.reverse) | |||
}).fmap(_.reverse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functor .map
syntax doesn't work for tuples in Scala 3 because there's polymorphic map
on Tuple
now.
@@ -630,7 +630,7 @@ case class NullableType( | |||
* | |||
* @see https://facebook.github.io/graphql/draft/#sec-The-__Field-Type | |||
*/ | |||
case class Field private( | |||
case class Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're calling this from a place that Scala 2 allows but Scala 3 doesn't. I don't think it needs to be private
anyway.
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package compiler | ||
|
||
import cats.Id | ||
import cats.implicits._ | ||
import cats.catsInstancesForId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala 3 can't find instances for cats.Id
but it's not clear why. This fixes it.
|
||
abstract class DoobieMapping[F[_]: Sync]( | ||
val transactor: Transactor[F], | ||
val monitor: DoobieMonitor[F] | ||
) extends SqlMapping[F] { | ||
|
||
type Codec[A] = (Meta[A], Boolean) | ||
type Encoder[A] = (Put[A], Boolean) | ||
type Encoder[-A] = (Put[A], Boolean) @uncheckedVariance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See SqlModule
for more on this.
@@ -190,7 +190,7 @@ trait SqlMapping[F[_]] extends CirceMapping[F] with SqlModule[F] { self => | |||
final class MappedQuery( | |||
table: String, | |||
columns: List[ColumnRef], | |||
metas: List[(Boolean, Codec[_])], | |||
metas: List[(Boolean, ExistentialCodec)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExistentialCodec
is defined in SqlModule
, see below.
@@ -14,8 +14,24 @@ trait SqlModule[F[_]] { | |||
/** The type of a codec that reads and writes column values of type `A`. */ | |||
type Codec[A] | |||
|
|||
/** A codec that has forgotten its type argument. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codec[_]
isn't a type in Scala 3 so we have to push the existential down into a type member.
/** The type of an encoder that writes column values of type `A`. */ | ||
type Encoder[A] | ||
type Encoder[-A] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Encoder
is invariant there are one million pages of type errors in MappedQuery
. Scala 2 is happy to crush stuff to Any
after a while but Scala 3 keeps up and doesn't like what's happening in calls to loop(...)
.
"io.circe" %% "circe-core" % circeVersion, | ||
"io.circe" %% "circe-optics" % circeOpticsVersion, | ||
"io.circe" %% "circe-parser" % circeVersion | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dependencies all arrive transitively so I removed them as a simplification. Same in a few places below.
@@ -193,7 +193,7 @@ Here the root of the result is "Luke Skywalker" and we loop back to Luke through | |||
The data type is not itself recursive, instead friend are identified by their ids. When traversing through the list of | |||
friends the `resolveFriends` method is used to locate the next `Character` value to visit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why this is being rendered in red.
@@ -5,6 +5,7 @@ package edu.gemini.grackle | |||
package circetests | |||
|
|||
import cats.Id | |||
import cats.catsInstancesForId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These instances are unavailable in Scala 3. I don't know why.
@@ -189,7 +189,7 @@ object GraphQLParser { | |||
QueryShorthand.widen[Ast.OperationDefinition] | Operation.widen | |||
|
|||
lazy val QueryShorthand: Parser[Ast.OperationDefinition.QueryShorthand] = | |||
SelectionSet.map(Ast.OperationDefinition.QueryShorthand) | |||
SelectionSet.map(Ast.OperationDefinition.QueryShorthand.apply) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala 3 warns that apply
-insertion is deprecated. I guess the companions no longer extend function types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Waiting on test-containers, which is having some issues. testcontainers/testcontainers-scala#177 |
test-containers is fixed, now waiting on cats-testkit-scalatest |
(updated to 3.0.0 final) |
Squashing since most commits don't build. |
resolves #104
This adds a cross-build for Scala 3.0.0.
JsonExtractors
and a bit ofACursor
bumbling in the tests.Codec[_]
forced me to writeExistentialCodec
which pushes the type parameter down into a type member. The Anti-Aux pattern.generic
is ported as-is, with all sources underscala-2
an publishing disabled for Scala 3. We can add Scala 3 support in a followup PR.TODO:
demo
(http4s is available now)