Skip to content

Commit 878c406

Browse files
Merge pull request #25 from lampepfl/upgrade-dotty
Upgrade Dotty to 0.23.0-RC1
2 parents 6c188ff + a3c6dae commit 878c406

File tree

9 files changed

+28
-29
lines changed

9 files changed

+28
-29
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val dottyVersion = "0.22.0-RC1" // dottyLatestNightlyBuild.get
1+
val dottyVersion = "0.23.0-RC1" // dottyLatestNightlyBuild.get
22

33
lazy val root = project
44
.in(file("."))

src/main/scala/dotty/xml/interpolator/internal/Expand.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object Expand {
4949
}
5050

5151
private def expandAttributes(attributes: Seq[Attribute])(implicit ctx: XmlContext, qctx: QuoteContext): Expr[scala.xml.MetaData] = {
52-
import qctx.tasty.{_, given}
52+
import qctx.tasty._
5353
attributes.foldRight('{ _root_.scala.xml.Null }: Expr[scala.xml.MetaData])((attribute, rest) => {
5454
val value = attribute.value match {
5555
case Seq(v) => expandNode(v)
@@ -88,7 +88,7 @@ object Expand {
8888
}
8989

9090
private def expandNamespaces(namespaces: Seq[Attribute])(implicit ctx: XmlContext, qctx: QuoteContext): Expr[scala.xml.NamespaceBinding] = {
91-
import qctx.tasty.{_, given}
91+
import qctx.tasty._
9292
namespaces.foldLeft(ctx.scope)((rest, namespace) => {
9393
val prefix = if (namespace.prefix.nonEmpty) Expr(namespace.key) else '{ null: String }
9494
val uri = (namespace.value.head: @unchecked) match {
@@ -99,25 +99,25 @@ object Expand {
9999
})
100100
}
101101

102-
private def expandText(text: Text)(given QuoteContext): Expr[scala.xml.Text] =
102+
private def expandText(text: Text)(using QuoteContext): Expr[scala.xml.Text] =
103103
'{ new _root_.scala.xml.Text(${Expr(text.text)}) }
104104

105-
private def expandComment(comment: Comment)(given QuoteContext): Expr[scala.xml.Comment] =
105+
private def expandComment(comment: Comment)(using QuoteContext): Expr[scala.xml.Comment] =
106106
'{ new _root_.scala.xml.Comment(${Expr(comment.text)}) }
107107

108108
private def expandPlaceholder(placeholder: Placeholder)(implicit ctx: XmlContext, qctx: QuoteContext): Expr[Any] = {
109109
Expr.betaReduceGiven(ctx.args(placeholder.id))(ctx.scope)
110110
}
111111

112-
private def expandPCData(pcdata: PCData)(given QuoteContext): Expr[scala.xml.PCData] =
112+
private def expandPCData(pcdata: PCData)(using QuoteContext): Expr[scala.xml.PCData] =
113113
'{ new _root_.scala.xml.PCData(${Expr(pcdata.data)}) }
114114

115-
private def expandProcInstr(instr: ProcInstr)(given QuoteContext): Expr[scala.xml.ProcInstr] =
115+
private def expandProcInstr(instr: ProcInstr)(using QuoteContext): Expr[scala.xml.ProcInstr] =
116116
'{ new _root_.scala.xml.ProcInstr(${Expr(instr.target)}, ${Expr(instr.proctext)}) }
117117

118-
private def expandEntityRef(ref: EntityRef)(given QuoteContext): Expr[scala.xml.EntityRef] =
118+
private def expandEntityRef(ref: EntityRef)(using QuoteContext): Expr[scala.xml.EntityRef] =
119119
'{ new _root_.scala.xml.EntityRef(${Expr(ref.name)}) }
120120

121-
private def expandUnparsed(unparsed: Unparsed)(given QuoteContext): Expr[scala.xml.Unparsed] =
121+
private def expandUnparsed(unparsed: Unparsed)(using QuoteContext): Expr[scala.xml.Unparsed] =
122122
'{ new _root_.scala.xml.Unparsed(${Expr(unparsed.data)}) }
123123
}

src/main/scala/dotty/xml/interpolator/internal/Macro.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ package dotty.xml.interpolator
22
package internal
33

44
import scala.quoted._
5-
import scala.quoted.autolift.given
6-
import scala.quoted.matching._
5+
import scala.quoted.autolift
76

87
import scala.collection.mutable.ArrayBuffer
98
import scala.language.implicitConversions
109

1110
object Macro {
1211

13-
def impl(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[(given Scope) => Any]], scope: Expr[Scope])(given qctx: QuoteContext): Expr[scala.xml.Node | scala.xml.NodeBuffer] = {
12+
def impl(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Scope ?=> Any]], scope: Expr[Scope])(using qctx: QuoteContext): Expr[scala.xml.Node | scala.xml.NodeBuffer] = {
1413
((strCtxExpr, argsExpr): @unchecked) match {
15-
case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args)) =>
14+
case ('{ StringContext(${Varargs(parts)}: _*) }, Varargs(args)) =>
1615
val (xmlStr, offsets) = encode(parts)
1716
implicit val ctx: XmlContext = new XmlContext(args, scope)
1817
implicit val reporter: Reporter = new Reporter {
19-
import qctx.tasty.{_, given}
18+
import qctx.tasty._
2019

2120
def error(msg: String, idx: Int): Unit = {
2221
val (part, offset) = Reporter.from(idx, offsets, parts)
@@ -33,14 +32,14 @@ object Macro {
3332
}
3433
}
3534

36-
def implErrors(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[(given Scope) => Any]], scope: Expr[Scope])(given qctx: QuoteContext): Expr[List[(Int, String)]] = {
35+
def implErrors(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Scope ?=> Any]], scope: Expr[Scope])(using qctx: QuoteContext): Expr[List[(Int, String)]] = {
3736
((strCtxExpr, argsExpr): @unchecked) match {
38-
case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args)) =>
37+
case ('{ StringContext(${Varargs(parts)}: _*) }, Varargs(args)) =>
3938
val errors = List.newBuilder[Expr[(Int, String)]]
4039
val (xmlStr, offsets) = encode(parts)
4140
implicit val ctx: XmlContext = new XmlContext(args, scope)
4241
implicit val reporter: Reporter = new Reporter {
43-
import qctx.tasty.{_, given}
42+
import qctx.tasty._
4443

4544
def error(msg: String, idx: Int): Unit = {
4645
val (part, offset) = Reporter.from(idx, offsets, parts)
@@ -58,7 +57,7 @@ object Macro {
5857
}
5958
}
6059

61-
private def implCore(xmlStr: String)(given XmlContext, Reporter, QuoteContext): Expr[scala.xml.Node | scala.xml.NodeBuffer] = {
60+
private def implCore(xmlStr: String)(using XmlContext, Reporter, QuoteContext): Expr[scala.xml.Node | scala.xml.NodeBuffer] = {
6261

6362
import Parse.{apply => parse}
6463
import Transform.{apply => transform}
@@ -77,7 +76,7 @@ object Macro {
7776
interpolate(xmlStr)
7877
}
7978

80-
private def encode(parts: Seq[Expr[String]])(given QuoteContext): (String, Array[Int]) = {
79+
private def encode(parts: Seq[Expr[String]])(using QuoteContext): (String, Array[Int]) = {
8180
val sb = new StringBuilder()
8281
val bf = ArrayBuffer.empty[Int]
8382

src/main/scala/dotty/xml/interpolator/internal/Parse.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object Parse extends JavaTokenParsers with TokenTests {
1313

1414
override val whiteSpace = "".r
1515

16-
def apply(input: String)(given reporter: Reporter): Seq[Tree.Node] = {
16+
def apply(input: String)(using reporter: Reporter): Seq[Tree.Node] = {
1717
parseAll(XmlExpr, input) match {
1818
case Success(result, _) => result
1919
case failed : NoSuccess => reporter.error(failed.msg, failed.next.pos); Nil

src/main/scala/dotty/xml/interpolator/internal/TypeCheck.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import scala.quoted._
66
import dotty.xml.interpolator.internal.Tree._
77

88
object TypeCheck {
9-
def apply(nodes: Seq[Node])(given XmlContext, Reporter, QuoteContext): Seq[Node] = {
9+
def apply(nodes: Seq[Node])(using XmlContext, Reporter, QuoteContext): Seq[Node] = {
1010
typecheck(nodes)
1111
nodes
1212
}
1313

14-
private def typecheck(nodes: Seq[Node])(given XmlContext, Reporter)(given qctx: QuoteContext): Unit = {
15-
import qctx.tasty.{_, given}
14+
private def typecheck(nodes: Seq[Node])(using XmlContext, Reporter)(using qctx: QuoteContext): Unit = {
15+
import qctx.tasty._
1616
nodes.foreach {
1717
case elem : Elem =>
1818
elem.attributes.foreach(attribute =>

src/main/scala/dotty/xml/interpolator/internal/Validate.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import scala.language.implicitConversions
66
import dotty.xml.interpolator.internal.Tree._
77

88
object Validate {
9-
def apply(nodes: Seq[Node])(given Reporter): Seq[Node] = {
9+
def apply(nodes: Seq[Node])(using Reporter): Seq[Node] = {
1010
mismatchedElements(nodes)
1111
duplicateAttributes(nodes)
1212
nodes
1313
}
1414

15-
private def mismatchedElements(nodes: Seq[Node])(given reporter: Reporter): Unit = {
15+
private def mismatchedElements(nodes: Seq[Node])(using reporter: Reporter): Unit = {
1616
nodes.foreach {
1717
case elem@Elem(name, _, _, Some(end)) =>
1818
if (name != end) reporter.error(s"closing tag `${name}` expected but `${end}` found", elem.pos)
@@ -21,7 +21,7 @@ object Validate {
2121
}
2222
}
2323

24-
private def duplicateAttributes(nodes: Seq[Node])(given reporter: Reporter): Unit = {
24+
private def duplicateAttributes(nodes: Seq[Node])(using reporter: Reporter): Unit = {
2525
nodes.foreach {
2626
case Elem(_, attributes, children, _) =>
2727
attributes

src/main/scala/dotty/xml/interpolator/internal/XmlContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package internal
33

44
import scala.quoted._
55

6-
class XmlContext(val args: Seq[Expr[(given Scope) => Any]], val scope: Expr[scala.xml.NamespaceBinding])
6+
class XmlContext(val args: Seq[Expr[Scope ?=> Any]], val scope: Expr[scala.xml.NamespaceBinding])

src/main/scala/dotty/xml/interpolator/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import scala.quoted._
55
type Scope = scala.xml.NamespaceBinding
66
implicit val top: Scope = scala.xml.TopScope
77

8-
inline def (inline ctx: StringContext) xml (inline args: ((given Scope) => Any)*)(given scope: Scope) <: Any =
8+
inline def (inline ctx: StringContext) xml (inline args: (Scope ?=> Any)*)(using scope: Scope) <: Any =
99
${ dotty.xml.interpolator.internal.Macro.impl('ctx, 'args, 'scope) }

src/test/scala/dotty/xml/interpolator/ReporterTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.junit.Assert._
55

66
class ReporterTest {
77

8-
inline def (inline ctx: StringContext) xml (inline args: ((given Scope) => Any)*)(given Scope) <: Any =
8+
inline def (inline ctx: StringContext) xml (inline args: (Scope ?=> Any)*)(using Scope) <: Any =
99
${ dotty.xml.interpolator.internal.Macro.implErrors('ctx, 'args, '{implicitly[Scope]}) }
1010

1111
@Test def empty1(): Unit = {

0 commit comments

Comments
 (0)