Skip to content

Commit 85c28c4

Browse files
committed
Merge branch 'cheeseng-feature-should-not-typecheck-dotty' into 3.1.x
2 parents 465c754 + b1feb76 commit 85c28c4

File tree

16 files changed

+209
-223
lines changed

16 files changed

+209
-223
lines changed

project/GenScalaTestDotty.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ object GenScalaTestDotty {
180180
List(
181181
"AssertionsSpec.scala",
182182
"ShouldCompileSpec.scala",
183-
"ShouldNotCompileSpec.scala"
183+
"ShouldNotCompileSpec.scala",
184+
"ShouldNotTypeCheckSpec.scala"
184185
)
185186
) /*++
186187
copyDir("scalatest-test/src/test/scala/org/scalatest/concurrent", "org/scalatest/concurrent", targetDir,

project/GenScalacticDotty.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,19 @@ object GenScalacticDotty {
149149
def genTest(targetDir: File, version: String, scalaVersion: String): Seq[File] =
150150
copyDir("scalactic-test/src/test/scala/org/scalactic", "org/scalactic", targetDir,
151151
List(
152-
"CanEqualSpec.scala", // NotImplementedError
153152
"ChainSpec.scala", // Compilation error to be investigated further
154153
"DecidersSpec.scala", // Compilation error to be investigated further
155154
"DifferSpec.scala", // Test failed when run to be investigate further.
156155
"DirectRequirementsSpec.scala", // macro expansion error: invalid prefix NoType
157156
"EverySpec.scala", // Compilation error to be investigated further
158-
"FutureSugarSpec.scala", // Implementation missing
159157
"NormalizationSpec.scala", // Compilation error to be investigated further.
160158
"NormMethodsSpec.scala", // Compilation error to be investigated further.
161159
"OrSpec.scala", // Compilation error to be investigated further.
162160
"PrettifierSpec.scala", // Test failed with java.lang.IllegalAccessException
163161
"RequirementsSpec.scala", // Error during macro expansion
164162
"SnapshotsSpec.scala", // Pending macro implementation
165163
"TolerantEquivalenceSpec.scala", // Compilation error to be investigated further.
166-
"TripleEqualsSpec.for210", // Old staff, we shall delete this soon.
167-
"TrySugarSpec.scala" // Not implemented error when test runs
164+
"TripleEqualsSpec.for210" // Old staff, we shall delete this soon.
168165
)) ++
169166
//copyDir("scalactic-test/src/test/scala/org/scalactic/anyvals", "org/scalactic/anyvals", targetDir, List.empty) ++
170167
copyDir("scalactic-test/src/test/scala/org/scalactic/source", "org/scalactic/source", targetDir, List.empty)

project/scalatest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ object ScalatestBuild {
597597
projectTitle := "Scalactic",
598598
organization := "org.scalactic",
599599
initialCommands in console := "import org.scalactic._",
600-
libraryDependencies ++= scalaXmlDependency(scalaVersion.value),
601600
sourceGenerators in Compile += {
602601
Def.task{
603602
// From scalactic-macro
@@ -2133,8 +2132,9 @@ object ScalatestBuild {
21332132
name.value)
21342133

21352134
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/
2137-
lazy val dottyVersion = dottyLatestNightlyBuild.get
2135+
// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.14/
2136+
//lazy val dottyVersion = dottyLatestNightlyBuild.get
2137+
lazy val dottyVersion = "0.14.0-bin-20190403-d00a7ba-NIGHTLY"
21382138
lazy val dottySettings = List(
21392139
scalaVersion := dottyVersion,
21402140
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value)),

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import scala.tasty._
2121
object BooleanMacro {
2222
def parse(condition: Expr[Boolean], prettifier: Expr[Prettifier])(implicit refl: Reflection): Expr[Bool] = {
2323
import refl._
24-
import quoted.Toolbox.Default._
24+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
2525
import util._
2626

2727
def exprStr: String = condition.show
@@ -30,35 +30,35 @@ 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 =>
37-
val l = left.seal[Any]
38-
val r = right.seal[Any]
39-
val b = result.seal[Boolean]
36+
let(Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil)) { result =>
37+
val l = left.seal
38+
val r = right.seal
39+
val b = result.seal.cast[Boolean]
4040
val code = '{ Bool.binaryMacroBool($l, ${ op.toExpr }, $r, $b, $prettifier) }
4141
code.unseal
4242
}
4343
}
44-
}.seal[Bool]
45-
case Term.Apply(sel @ Term.Select(lhs, op), rhs :: Nil) =>
44+
}.seal.cast[Bool]
45+
case Apply(sel @ Select(lhs, op), rhs :: Nil) =>
4646
op match {
4747
case "||" =>
48-
val left = parse(lhs.seal[Boolean], prettifier)
49-
val right = parse(rhs.seal[Boolean], prettifier)
48+
val left = parse(lhs.seal.cast[Boolean], prettifier)
49+
val right = parse(rhs.seal.cast[Boolean], prettifier)
5050
'{ $left || $right }
5151
case "|" =>
52-
val left = parse(lhs.seal[Boolean], prettifier)
53-
val right = parse(rhs.seal[Boolean], prettifier)
52+
val left = parse(lhs.seal.cast[Boolean], prettifier)
53+
val right = parse(rhs.seal.cast[Boolean], prettifier)
5454
'{ $left | $right }
5555
case "&&" =>
56-
val left = parse(lhs.seal[Boolean], prettifier)
57-
val right = parse(rhs.seal[Boolean], prettifier)
56+
val left = parse(lhs.seal.cast[Boolean], prettifier)
57+
val right = parse(rhs.seal.cast[Boolean], prettifier)
5858
'{ $left && $right }
5959
case "&" =>
60-
val left = parse(lhs.seal[Boolean], prettifier)
61-
val right = parse(rhs.seal[Boolean], prettifier)
60+
val left = parse(lhs.seal.cast[Boolean], prettifier)
61+
val right = parse(rhs.seal.cast[Boolean], prettifier)
6262
'{ $left & $right }
6363
case _ =>
6464
sel.tpe.widen match {
@@ -67,36 +67,36 @@ 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 =>
73-
val l = left.seal[Any]
74-
val r = right.seal[Any]
75-
val b = result.seal[Boolean]
73+
val l = left.seal
74+
val r = right.seal
75+
val b = result.seal.cast[Boolean]
7676
val code = '{ Bool.binaryMacroBool($l, ${op.toExpr}, $r, $b, $prettifier) }
7777
code.unseal
7878
}
7979
}
80-
}.seal[Bool]
80+
}.seal.cast[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 =>
88-
val l = left.seal[Any]
89-
val r = right.seal[Any]
90-
val b = result.seal[Boolean]
87+
let(Apply(Select.overloaded(Apply(qual, left :: Nil), op, Nil, right :: Nil), implicits)) { result =>
88+
val l = left.seal
89+
val r = right.seal
90+
val b = result.seal.cast[Boolean]
9191
val code = '{ Bool.binaryMacroBool($l, ${ op.toExpr }, $r, $b, $prettifier) }
9292
code.unseal
9393
}
9494
}
95-
}.seal[Bool]
96-
case Term.Select(left, "unary_!") =>
97-
val receiver = parse(left.seal[Boolean], prettifier)
95+
}.seal.cast[Bool]
96+
case Select(left, "unary_!") =>
97+
val receiver = parse(left.seal.cast[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: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ object RequirementsMacro {
233233
*/
234234
def require(condition: Expr[Boolean], prettifier: Expr[Prettifier], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = {
235235
import refl._
236-
import quoted.Toolbox.Default._
237-
236+
238237
val bool = BooleanMacro.parse(condition, prettifier)
239238
'{ Requirements.requirementsHelper.macroRequire($bool, $clue) }
240239
}
@@ -248,8 +247,7 @@ object RequirementsMacro {
248247
*/
249248
def requireState(condition: Expr[Boolean], prettifier: Expr[Prettifier], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = {
250249
import refl._
251-
import quoted.Toolbox.Default._
252-
250+
253251
val bool = BooleanMacro.parse(condition, prettifier)
254252
'{ Requirements.requirementsHelper.macroRequireState($bool, $clue) }
255253
}
@@ -263,8 +261,7 @@ object RequirementsMacro {
263261
*/
264262
def requireNonNull(arguments: Expr[Seq[Any]], prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit reflect: Reflection): Expr[Unit] = {
265263
import reflect._
266-
import Term._
267-
import quoted.Toolbox.Default._
264+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
268265

269266
def liftSeq(args: Seq[Expr[String]]): Expr[Seq[String]] = args match {
270267
case x :: xs => '{ ($x) +: ${ liftSeq(xs) } }
@@ -273,7 +270,7 @@ object RequirementsMacro {
273270

274271
val argStr: List[Expr[String]] = arguments.unseal.underlyingArgument match {
275272
case Typed(Repeated(args, _), _) => // only sequence literal
276-
args.map(arg => arg.seal[Any].show.toExpr)
273+
args.map(arg => arg.seal.cast[Any].show.toExpr)
277274
case _ =>
278275
throw QuoteError("requireNonNull can only be used with sequence literal, not `seq : _*`")
279276
}

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ 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))
211-
throw new TastyTypecheckError(notValidMsg)
211+
throw new scala.tasty.reflect.ExprCastError(notValidMsg)
212212
case _ =>
213-
throw new TastyTypecheckError(notLiteralMsg)
213+
throw new scala.tasty.reflect.ExprCastError(notLiteralMsg)
214214
}
215215
}
216216

@@ -240,12 +240,12 @@ 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))
246-
throw new TastyTypecheckError(notValidMsg)
246+
throw new scala.tasty.reflect.ExprCastError(notValidMsg)
247247
case _ =>
248-
throw new TastyTypecheckError(notLiteralMsg)
248+
throw new scala.tasty.reflect.ExprCastError(notLiteralMsg)
249249
}
250250
}
251251

@@ -275,12 +275,12 @@ 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))
281-
throw new TastyTypecheckError(notValidMsg)
281+
throw new scala.tasty.reflect.ExprCastError(notValidMsg)
282282
case _ =>
283-
throw new TastyTypecheckError(notLiteralMsg)
283+
throw new scala.tasty.reflect.ExprCastError(notLiteralMsg)
284284
}
285285
}
286286

@@ -310,12 +310,12 @@ 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))
316-
throw new TastyTypecheckError(notValidMsg)
316+
throw new scala.tasty.reflect.ExprCastError(notValidMsg)
317317
case _ =>
318-
throw new TastyTypecheckError(notLiteralMsg)
318+
throw new scala.tasty.reflect.ExprCastError(notLiteralMsg)
319319
}
320320
}
321321

@@ -345,12 +345,12 @@ 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))
351-
throw new TastyTypecheckError(notValidMsg)
351+
throw new scala.tasty.reflect.ExprCastError(notValidMsg)
352352
case _ =>
353-
throw new TastyTypecheckError(notLiteralMsg)
353+
throw new scala.tasty.reflect.ExprCastError(notLiteralMsg)
354354
}
355355
}
356356

@@ -380,12 +380,12 @@ 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))
386-
throw new TastyTypecheckError(notValidMsg)
386+
throw new scala.tasty.reflect.ExprCastError(notValidMsg)
387387
case _ =>
388-
throw new TastyTypecheckError(notLiteralMsg)
388+
throw new scala.tasty.reflect.ExprCastError(notLiteralMsg)
389389
}
390390
}
391391
}

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
""

0 commit comments

Comments
 (0)