Skip to content

Commit 9082a49

Browse files
committed
Updated dotty macro implementation code for dotty 20190401 build.
1 parent 0f9eac2 commit 9082a49

File tree

9 files changed

+20
-30
lines changed

9 files changed

+20
-30
lines changed

project/scalatest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,9 +2133,9 @@ object ScalatestBuild {
21332133
name.value)
21342134

21352135
import dotty.tools.sbtplugin.DottyPlugin.autoImport._
2136-
// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.13/
2136+
// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.14/
21372137
//lazy val dottyVersion = dottyLatestNightlyBuild.get
2138-
lazy val dottyVersion = "0.14.0-bin-20190331-c059b64-NIGHTLY"
2138+
lazy val dottyVersion = "0.14.0-bin-20190401-f62e286-NIGHTLY"
21392139
lazy val dottySettings = List(
21402140
scalaVersion := dottyVersion,
21412141
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value)),

scalactic.dotty/src/main/scala/org/scalactic/BooleanMacro.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ object BooleanMacro {
3030
Type.IsMethodType.unapply(tp).flatMap(tp => if tp.isImplicit then Some(true) else None).nonEmpty
3131

3232
condition.unseal.underlyingArgument match {
33-
case Term.Apply(Term.Select(Term.Apply(qual, lhs :: Nil), op @ ("===" | "!==")), rhs :: Nil) =>
33+
case Apply(Select(Apply(qual, lhs :: Nil), op @ ("===" | "!==")), rhs :: Nil) =>
3434
let(lhs) { left =>
3535
let(rhs) { right =>
36-
let(Term.Select.overloaded(Term.Apply(qual, left :: Nil), op, Nil, right :: Nil)) { result =>
36+
let(Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil)) { result =>
3737
val l = left.seal[Any]
3838
val r = right.seal[Any]
3939
val b = result.seal[Boolean]
@@ -42,7 +42,7 @@ object BooleanMacro {
4242
}
4343
}
4444
}.seal[Bool]
45-
case Term.Apply(sel @ Term.Select(lhs, op), rhs :: Nil) =>
45+
case Apply(sel @ Select(lhs, op), rhs :: Nil) =>
4646
op match {
4747
case "||" =>
4848
val left = parse(lhs.seal[Boolean], prettifier)
@@ -67,7 +67,7 @@ object BooleanMacro {
6767
case _ =>
6868
let(lhs) { left =>
6969
let(rhs) { right =>
70-
val app = Term.Select.overloaded(left, op, Nil, right :: Nil)
70+
val app = Select.overloaded(left, op, Nil, right :: Nil)
7171
assert(app.symbol == sel.symbol, app.symbol.fullName -> sel.symbol.fullName)
7272
let(app) { result =>
7373
val l = left.seal[Any]
@@ -80,11 +80,11 @@ object BooleanMacro {
8080
}.seal[Bool]
8181
}
8282
}
83-
case Term.Apply(f @ Term.Apply(Term.Select(Term.Apply(qual, lhs :: Nil), op @ ("===" | "!==")), rhs :: Nil), implicits)
83+
case Apply(f @ Apply(Select(Apply(qual, lhs :: Nil), op @ ("===" | "!==")), rhs :: Nil), implicits)
8484
if isImplicitMethodType(f.tpe) =>
8585
let(lhs) { left =>
8686
let(rhs) { right =>
87-
let(Term.Apply(Term.Select.overloaded(Term.Apply(qual, left :: Nil), op, Nil, right :: Nil), implicits)) { result =>
87+
let(Apply(Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil), implicits)) { result =>
8888
val l = left.seal[Any]
8989
val r = right.seal[Any]
9090
val b = result.seal[Boolean]
@@ -93,10 +93,10 @@ object BooleanMacro {
9393
}
9494
}
9595
}.seal[Bool]
96-
case Term.Select(left, "unary_!") =>
96+
case Select(left, "unary_!") =>
9797
val receiver = parse(left.seal[Boolean], prettifier)
9898
'{ !($receiver) }
99-
case Term.Literal(_) =>
99+
case Literal(_) =>
100100
'{ Bool.simpleMacroBool($condition, "", $prettifier) }
101101
case _ =>
102102
defaultCase

scalactic.dotty/src/main/scala/org/scalactic/Requirements.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ object RequirementsMacro {
263263
*/
264264
def requireNonNull(arguments: Expr[Seq[Any]], prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit reflect: Reflection): Expr[Unit] = {
265265
import reflect._
266-
import Term._
267266
import quoted.Toolbox.Default._
268267

269268
def liftSeq(args: Seq[Expr[String]]): Expr[Seq[String]] = args match {

scalactic.dotty/src/main/scala/org/scalactic/anyvals/CompileTimeAssertions.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ trait CompileTimeAssertions {
205205
import refl._
206206

207207
value.unseal.underlyingArgument match {
208-
case Term.Literal(intConst) =>
208+
case Literal(intConst) =>
209209
val literalValue = intConst.value.toString.toInt
210210
if (!isValid(literalValue))
211211
throw new TastyTypecheckError(notValidMsg)
@@ -240,7 +240,7 @@ trait CompileTimeAssertions {
240240
import refl._
241241

242242
value.unseal.underlyingArgument match {
243-
case Term.Literal(longConst) =>
243+
case Literal(longConst) =>
244244
val literalValue = longConst.value.toString.toLong
245245
if (!isValid(literalValue))
246246
throw new TastyTypecheckError(notValidMsg)
@@ -275,7 +275,7 @@ trait CompileTimeAssertions {
275275
import refl._
276276

277277
value.unseal.underlyingArgument match {
278-
case Term.Literal(floatConst) =>
278+
case Literal(floatConst) =>
279279
val literalValue = floatConst.value.toString.toFloat
280280
if (!isValid(literalValue))
281281
throw new TastyTypecheckError(notValidMsg)
@@ -310,7 +310,7 @@ trait CompileTimeAssertions {
310310
import refl._
311311

312312
value.unseal.underlyingArgument match {
313-
case Term.Literal(doubleConst) =>
313+
case Literal(doubleConst) =>
314314
val literalValue = doubleConst.value.toString.toDouble
315315
if (!isValid(literalValue))
316316
throw new TastyTypecheckError(notValidMsg)
@@ -345,7 +345,7 @@ trait CompileTimeAssertions {
345345
import refl._
346346

347347
value.unseal.underlyingArgument match {
348-
case Term.Literal(stringConst) =>
348+
case Literal(stringConst) =>
349349
val literalValue = stringConst.value.toString
350350
if (!isValid(literalValue))
351351
throw new TastyTypecheckError(notValidMsg)
@@ -380,7 +380,7 @@ trait CompileTimeAssertions {
380380
import refl._
381381

382382
value.unseal.underlyingArgument match {
383-
case Term.Literal(charConst) =>
383+
case Literal(charConst) =>
384384
val literalValue = charConst.value.toString.head
385385
if (!isValid(literalValue))
386386
throw new TastyTypecheckError(notValidMsg)

scalactic.dotty/src/main/scala/org/scalactic/anyvals/RegexStringMacro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private[scalactic] object RegexStringMacro {
4848

4949
val notValidExceptionMsg: String = {
5050
value.unseal match {
51-
case Term.Literal(stringConst) =>
51+
case Literal(stringConst) =>
5252
checkIsValid(stringConst.value.toString)._2
5353
case _ =>
5454
""

scalatest.dotty/src/main/scala/org/scalatest/CompileMacro.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ object CompileMacro {
164164
// check that a code snippet does not compile
165165
def assertNotCompileImpl[T](self: Expr[T], compileWord: Expr[CompileWord], pos: Expr[source.Position])(shouldOrMust: String)(implicit refl: Reflection): Expr[Assertion] = {
166166
import refl._
167-
import Term._
168167
import Constant._
169168

170169
// parse and type check a code snippet, generate code to throw TestFailedException if both parse and type check succeeded
@@ -216,7 +215,6 @@ object CompileMacro {
216215
// check that a code snippet does not compile
217216
def assertNotTypeCheckImpl(self: Expr[Matchers#AnyShouldWrapper[_]], typeCheckWord: Expr[TypeCheckWord], pos: Expr[source.Position])(shouldOrMust: String)(implicit refl: Reflection): Expr[Assertion] = {
218217
import refl._
219-
import Term._
220218
import Constant._
221219

222220
// parse and type check a code snippet, generate code to throw TestFailedException if both parse and type check succeeded
@@ -270,7 +268,6 @@ object CompileMacro {
270268
// check that a code snippet compiles
271269
def assertCompileImpl[T](self: Expr[T], compileWord: Expr[CompileWord], pos: Expr[source.Position])(shouldOrMust: String)(implicit refl: Reflection): Expr[Assertion] = {
272270
import refl._
273-
import Term._
274271
import Constant._
275272

276273
// parse and type check a code snippet, generate code to throw TestFailedException if both parse and type check succeeded

scalatest.dotty/src/main/scala/org/scalatest/DiagrammedAssertionsMacro.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ private[scalatest] object DiagrammedAssertionsMacro {
3131
prettifier: Expr[Prettifier],
3232
pos: Expr[source.Position])(implicit refl: Reflection): Expr[Assertion] = {
3333
import refl._
34-
import Term._
3534
import quoted.Toolbox.Default._
3635

3736
val startLine = refl.rootPosition.startLine // Get the expression first line number

scalatest.dotty/src/main/scala/org/scalatest/DiagrammedExprMacro.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ object DiagrammedExprMacro {
3939
def parse[T:Type](expr: Expr[T])(implicit refl: Reflection): Expr[DiagrammedExpr[T]] = {
4040
import refl._
4141
import quoted.Toolbox.Default._
42-
import Term._
4342

4443
def isXmlSugar(apply: Apply): Boolean = apply.tpe <:< typeOf[scala.xml.Elem]
4544
def isJavaStatic(tree: Tree): Boolean = tree.symbol.flags.is(Flags.Static)
@@ -63,13 +62,12 @@ object DiagrammedExprMacro {
6362
def applyExpr[T:Type](expr: Expr[T])(implicit refl: Reflection): Expr[DiagrammedExpr[T]] = {
6463
import refl._
6564
import quoted.Toolbox.Default._
66-
import Term._
6765

6866
def apply(l: Expr[_], name: String, r: List[Expr[_]]): Expr[T] =
69-
Term.Select.overloaded(l.unseal, name, Nil, r.map(_.unseal)).seal[T]
67+
Select.overloaded(l.unseal, name, Nil, r.map(_.unseal)).seal[T]
7068

7169
expr.unseal.underlyingArgument match {
72-
case Term.Apply(Term.Select(lhs, op), rhs :: Nil) =>
70+
case Apply(Select(lhs, op), rhs :: Nil) =>
7371
op match {
7472
case "||" | "|" =>
7573
val left = parse(lhs.seal[T & Boolean])
@@ -99,7 +97,7 @@ object DiagrammedExprMacro {
9997
DiagrammedExpr.applyExpr(l, r :: Nil, res, ${ getAnchor(expr) })
10098
}
10199
}
102-
case Term.Apply(Term.Select(lhs, op), args) =>
100+
case Apply(Select(lhs, op), args) =>
103101
val left = parse(lhs.seal[Any])
104102
val rights = args.map(arg => parse(arg.seal[Any]))
105103

@@ -117,7 +115,6 @@ object DiagrammedExprMacro {
117115
def selectExpr[T:Type](expr: Expr[T])(implicit refl: Reflection): Expr[DiagrammedExpr[T]] = {
118116
import refl._
119117
import quoted.Toolbox.Default._
120-
import Term._
121118

122119
def selectField(o: Expr[_], name: String): Expr[T] = ???
123120

scalatest.dotty/src/main/scala/org/scalatest/matchers/TypeMatcherMacro.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ private[scalatest] object TypeMatcherMacro {
2929
// // Check that no type parameter is specified, if any does, give a friendly compiler warning.
3030
def checkTypeParameter(refl: Reflection)(tree: refl.Term, methodName: String): Unit = {
3131
import refl._
32-
import Term._
33-
import TypeTree._
3432
import quoted.Toolbox.Default._
3533

3634
// TODO#Macros: Select lack unapply

0 commit comments

Comments
 (0)