Skip to content

Commit 6e6922c

Browse files
committed
Upgrade to Scala 3.0.0-RC1
1 parent c9fd879 commit 6e6922c

File tree

29 files changed

+59
-68
lines changed

29 files changed

+59
-68
lines changed

build.sc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import $file.example.websockets3.build
2727
import $file.example.websockets4.build
2828

2929
val scala213 = "2.13.4"
30-
val scala3 = "3.0.0-M2"
30+
val scala3 = "3.0.0-RC1"
3131
val dottyCustomVersion = Option(sys.props("dottyVersion"))
3232

3333
trait CaskModule extends CrossScalaModule with PublishModule{
@@ -51,7 +51,7 @@ class CaskMainModule(val crossScalaVersion: String) extends CaskModule {
5151
def ivyDeps = T{
5252
Agg(
5353
ivy"io.undertow:undertow-core:2.2.3.Final",
54-
ivy"com.lihaoyi::upickle:1.2.2"
54+
ivy"com.lihaoyi::upickle:1.2.3"
5555
) ++
5656
(if(!isDotty) Agg(ivy"org.scala-lang:scala-reflect:${scalaVersion()}") else Agg())
5757
}
@@ -62,7 +62,7 @@ class CaskMainModule(val crossScalaVersion: String) extends CaskModule {
6262
object test extends Tests{
6363
def testFrameworks = Seq("utest.runner.Framework")
6464
def ivyDeps = Agg(
65-
ivy"com.lihaoyi::utest::0.7.5",
65+
ivy"com.lihaoyi::utest::0.7.7",
6666
ivy"com.lihaoyi::requests::0.6.5"
6767
)
6868
}
@@ -81,9 +81,9 @@ object cask extends Cross[CaskMainModule]((Seq(scala213, scala3) ++ dottyCustomV
8181
millSourcePath / s"src-$platformSegment"
8282
)
8383
def ivyDeps = Agg(
84-
ivy"com.lihaoyi::sourcecode:0.2.1",
85-
ivy"com.lihaoyi::pprint:0.6.0",
86-
ivy"com.lihaoyi::geny:0.6.2"
84+
ivy"com.lihaoyi::sourcecode:0.2.3",
85+
ivy"com.lihaoyi::pprint:0.6.1",
86+
ivy"com.lihaoyi::geny:0.6.5"
8787
)
8888
}
8989
class UtilJvmModule(val crossScalaVersion: String) extends UtilModule {

cask/src-3/cask/router/Macros.scala

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object Macros {
4545

4646
val idents = method.owner.tree.asInstanceOf[ClassDef].body
4747
idents.foreach{
48-
case deff @ DefDef(Name(idx), _, _, _, tree) =>
48+
case deff @ DefDef(Name(idx), _, _, _) =>
4949
val expr = Ref(deff.symbol).asExpr
5050
defaults += (params(idx.toInt - 1) -> expr)
5151
case _ =>
@@ -65,7 +65,7 @@ object Macros {
6565
val paramTpt = param.tree.asInstanceOf[ValDef].tpt
6666
val inputReaderTypeRaw = Applied(
6767
TypeSelect(
68-
Term.of(decorator),
68+
decorator.asTerm,
6969
"InputParser"
7070
),
7171
List(paramTpt)
@@ -74,9 +74,9 @@ object Macros {
7474

7575
val reader = Expr.summon(using inputReaderType) match {
7676
case None =>
77-
Reporting.error(
77+
report.error(
7878
s"no reader of type ${paramTpt.tpe.typeSymbol.fullName} found for parameter ${param.name}",
79-
param.pos
79+
param.pos.get
8080
)
8181
'{???}
8282
case Some(expr) => expr
@@ -111,7 +111,7 @@ object Macros {
111111
val paramss = method.paramSymss
112112

113113
if (paramss.isEmpty) {
114-
Reporting.error("At least one parameter list must be declared.", method.pos)
114+
report.error("At least one parameter list must be declared.", method.pos.get)
115115
return '{???}
116116
}
117117

@@ -123,7 +123,7 @@ object Macros {
123123
val e = '{
124124
$argss(${Expr(i)})(${Expr(j)}).asInstanceOf[$t]
125125
}
126-
Term.of(e)
126+
e.asTerm
127127
}
128128
}
129129

@@ -150,29 +150,23 @@ object Macros {
150150
): Expr[Any] = {
151151
import qctx.reflect._
152152

153-
val innerReturnedTpt = TypeSelect(
154-
Term.of(endpoint),
155-
"InnerReturnedAlias"
156-
)
157-
158-
val rtpt = method.tree.asInstanceOf[DefDef].returnTpt
153+
val innerReturnedTpt = endpoint.asTerm.tpe.asType match {
154+
case '[Endpoint[_, innerReturned, _]] => TypeRepr.of[innerReturned]
155+
case _ => ???
156+
}
159157

160-
val conversionTpeRaw = Applied(
161-
TypeTree.of[cask.internal.Conversion],
162-
List(
163-
rtpt, innerReturnedTpt
164-
)
165-
).tpe
158+
val rtp = method.tree.asInstanceOf[DefDef].returnTpt.tpe
166159

167-
// the asInstanceOf is required to splice this back into an Expr; this is generally
168-
// unsafe, but we know that it will work in the context that this macro is invoked in
169-
val conversionTpe = conversionTpeRaw.asType.asInstanceOf[Type[Any]]
160+
val conversionTpe = TypeRepr.of[cask.internal.Conversion].appliedTo(
161+
List(rtp, innerReturnedTpt)
162+
)
170163

171-
val conversion = Expr.summon(using conversionTpe) match {
172-
case None =>
173-
Reporting.error(s"can't convert ${rtpt.tpe.typeSymbol.fullName} to a response", method.pos)
164+
val conversion = Implicits.search(conversionTpe) match {
165+
case iss: ImplicitSearchSuccess =>
166+
iss.tree.asExpr
167+
case isf: ImplicitSearchFailure =>
168+
report.error(s"can't convert ${rtp.typeSymbol.fullName} to a response", method.pos.get)
174169
'{???}
175-
case Some(expr) => expr
176170
}
177171

178172
'{
@@ -228,7 +222,7 @@ object Macros {
228222
val decoTpe = (decorator match {
229223
case Some(deco) =>
230224
TypeSelect(
231-
Term.of(deco),
225+
deco.asTerm,
232226
"InputTypeAlias"
233227
).tpe.asType
234228
case None =>
@@ -281,10 +275,10 @@ object Macros {
281275
}
282276

283277
Runtime.validateLists(parsedArgss).map{ validated =>
284-
val result = ${call(method, '{validated})}
278+
val result = ${call(using qctx)(method, '{validated})}
285279

286280
${
287-
convertToResponse(
281+
convertToResponse(using qctx)(
288282
method,
289283
endpoint,
290284
'{result}

cask/src-3/cask/router/RoutesEndpointMetadata.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ case class RoutesEndpointsMetadata[T](value: Seq[EndpointMetadata[T]])
66
object RoutesEndpointsMetadata{
77
import scala.quoted._
88

9-
inline given initialize[T] as RoutesEndpointsMetadata[T] = ${initializeImpl}
9+
inline given initialize[T]: RoutesEndpointsMetadata[T] = ${initializeImpl}
1010

1111
def setRoutesImpl[T](setter: Expr[RoutesEndpointsMetadata[T] => Unit])
1212
(using qctx: Quotes, tpe: Type[T]): Expr[Unit] = {
@@ -20,21 +20,21 @@ object RoutesEndpointsMetadata{
2020
import qctx.reflect._
2121

2222
val routeParts: List[Expr[EndpointMetadata[T]]] = for {
23-
m <- TypeRepr.of(using tpe).typeSymbol.methods
24-
annotations = m.annots.filter(_.tpe <:< TypeRepr.of[Decorator[_, _, _]])
23+
m <- TypeRepr.of(using tpe).typeSymbol.memberMethods
24+
annotations = m.annotations.filter(_.tpe <:< TypeRepr.of[Decorator[_, _, _]])
2525
if (annotations.nonEmpty)
2626
} yield {
2727

2828
if(!(annotations.head.tpe <:< TypeRepr.of[Endpoint[_, _, _]])) {
29-
Reporting.error(s"Last annotation applied to a function must be an instance of Endpoint, " +
29+
report.error(s"Last annotation applied to a function must be an instance of Endpoint, " +
3030
s"not ${annotations.head.tpe.show}",
3131
annotations.head.pos
3232
)
3333
return '{???} // in this case, we can't continue expansion of this macro
3434
}
3535
val allEndpoints = annotations.filter(_.tpe <:< TypeRepr.of[Endpoint[_, _, _]])
3636
if(allEndpoints.length > 1) {
37-
Reporting.error(
37+
report.error(
3838
s"You can only apply one Endpoint annotation to a function, not " +
3939
s"${allEndpoints.length} in ${allEndpoints.map(_.tpe.show).mkString(", ")}",
4040
annotations.last.pos,
@@ -52,7 +52,7 @@ object RoutesEndpointsMetadata{
5252
'{
5353

5454
val entrypoint: EntryPoint[T, cask.Request] = ${
55-
Macros.extractMethod[T](
55+
Macros.extractMethod[T](using qctx)(
5656
m,
5757
decorators,
5858
endpoint

cask/src/cask/router/Decorators.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ trait RawDecorator extends Decorator[Response.Raw, Response.Raw, Any]{
8181
trait Endpoint[OuterReturned, InnerReturned, Input]
8282
extends Decorator[OuterReturned, InnerReturned, Input]{
8383

84-
// used internally to facilitate access to the type in macros
85-
type InnerReturnedAlias = InnerReturned
86-
8784
/**
8885
* What is the path that this particular endpoint matches?
8986
*/

example/compress/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait AppModule extends CrossScalaModule{
1010
def testFrameworks = Seq("utest.runner.Framework")
1111

1212
def ivyDeps = Agg(
13-
ivy"com.lihaoyi::utest::0.7.5",
13+
ivy"com.lihaoyi::utest::0.7.7",
1414
ivy"com.lihaoyi::requests::0.6.5",
1515
)
1616
}

example/compress2/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/compress3/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/cookies/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/decorated/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/decorated2/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/endpoints/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/formJsonPost/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5"
1414
)
1515
}

example/httpMethods/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/minimalApplication/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/minimalApplication2/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/redirectAbort/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/scalatags/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait AppModule extends CrossScalaModule{
1111
def testFrameworks = Seq("utest.runner.Framework")
1212

1313
def ivyDeps = Agg(
14-
ivy"com.lihaoyi::utest::0.7.5",
14+
ivy"com.lihaoyi::utest::0.7.7",
1515
ivy"com.lihaoyi::requests::0.6.5",
1616
)
1717
}

example/staticFiles/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait AppModule extends CrossScalaModule{
1111
def testFrameworks = Seq("utest.runner.Framework")
1212

1313
def ivyDeps = Agg(
14-
ivy"com.lihaoyi::utest::0.7.5",
14+
ivy"com.lihaoyi::utest::0.7.7",
1515
ivy"com.lihaoyi::requests::0.6.5",
1616
)
1717

example/staticFiles2/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait AppModule extends CrossScalaModule{
1111
def testFrameworks = Seq("utest.runner.Framework")
1212

1313
def ivyDeps = Agg(
14-
ivy"com.lihaoyi::utest::0.7.5",
14+
ivy"com.lihaoyi::utest::0.7.7",
1515
ivy"com.lihaoyi::requests::0.6.5",
1616
)
1717

example/todo/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait AppModule extends CrossScalaModule{
1313
def testFrameworks = Seq("utest.runner.Framework")
1414

1515
def ivyDeps = Agg(
16-
ivy"com.lihaoyi::utest::0.7.5",
16+
ivy"com.lihaoyi::utest::0.7.7",
1717
ivy"com.lihaoyi::requests::0.6.5",
1818
)
1919
}

example/todoApi/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/todoDb/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait AppModule extends CrossScalaModule{
1212
def testFrameworks = Seq("utest.runner.Framework")
1313

1414
def ivyDeps = Agg(
15-
ivy"com.lihaoyi::utest::0.7.5",
15+
ivy"com.lihaoyi::utest::0.7.7",
1616
ivy"com.lihaoyi::requests::0.6.5",
1717
)
1818
}

example/twirl/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait AppModule extends CrossScalaModule with mill.twirllib.TwirlModule{
1515
def testFrameworks = Seq("utest.runner.Framework")
1616

1717
def ivyDeps = Agg(
18-
ivy"com.lihaoyi::utest::0.7.5",
18+
ivy"com.lihaoyi::utest::0.7.7",
1919
ivy"com.lihaoyi::requests::0.6.5",
2020
)
2121
}

example/variableRoutes/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
)
1515
}

example/websockets/build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait AppModule extends CrossScalaModule{
99
def testFrameworks = Seq("utest.runner.Framework")
1010

1111
def ivyDeps = Agg(
12-
ivy"com.lihaoyi::utest::0.7.5",
12+
ivy"com.lihaoyi::utest::0.7.7",
1313
ivy"com.lihaoyi::requests::0.6.5",
1414
ivy"org.asynchttpclient:async-http-client:2.5.2"
1515
)

0 commit comments

Comments
 (0)