Skip to content

Commit 3164441

Browse files
committed
Merge branch 'cheeseng-dotty-fix-20190731' into 3.1.x
2 parents 90e98b8 + 9d39a88 commit 3164441

File tree

58 files changed

+317
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+317
-304
lines changed

common-test.dotty/src/main/scala/org/scalatest/LineNumberHelper.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ private[scalatest] trait LineNumberHelper {
88
}
99

1010
object LineNumberMacro {
11-
def thisLineNumberImpl(implicit refl: Reflection): Expr[Int] = {
12-
import refl._
13-
14-
refl.rootPosition.startLine.toExpr
11+
def thisLineNumberImpl(implicit qctx: QuoteContext): Expr[Int] = {
12+
import qctx.tasty._
13+
rootPosition.startLine.toExpr
1514
}
1615
}

common-test/src/main/scala/org/scalatest/prop/CommonGenerators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,7 @@ trait CommonGenerators {
24032403
// classify will need to use the same sizing algo as forAll, and same edges approach
24042404
def classify[A](count: PosInt, genOfA: Generator[A])(pf: PartialFunction[A, String]): Classification = {
24052405

2406-
val (initEdges, rnd1) = genOfA.initEdges(100, Randomizer.default())
2406+
val (initEdges, rnd1) = genOfA.initEdges(100, Randomizer.default)
24072407
@tailrec
24082408
def loop(currentCount: Int, edges: List[A], rnd: Randomizer, acc: Map[String, PosZInt]): Map[String, PosZInt] = {
24092409
if (currentCount >= count) acc

common-test/src/main/scala/org/scalatest/prop/Randomizer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ object Randomizer {
22042204
/**
22052205
* This seed is empty under ordinary circumstances. It is here so that the test
22062206
* Runner can poke in a seed value to be used during a test run. If set, it will be used
2207-
* as the seed for all calls to [[Randomizer.default()]].
2207+
* as the seed for all calls to [[Randomizer.default]].
22082208
*/
22092209
private[scalatest] val defaultSeed: AtomicReference[Option[Long]] = new AtomicReference(None)
22102210

@@ -2216,7 +2216,7 @@ object Randomizer {
22162216
*
22172217
* @return A Randomizer, ready to begin producing random values.
22182218
*/
2219-
def default(): Randomizer =
2219+
def default: Randomizer =
22202220
apply(
22212221
defaultSeed.get() match {
22222222
case Some(seed) => seed
@@ -2236,7 +2236,7 @@ object Randomizer {
22362236
* your "random" events.
22372237
*
22382238
* If you want to create an adequate seed to feed into here, the value of [[System.currentTimeMillis()]] is
2239-
* reasonable (and is used in [[Randomizer.default()]]). It's a somewhat weak seed, but decent for most
2239+
* reasonable (and is used in [[Randomizer.default]]). It's a somewhat weak seed, but decent for most
22402240
* purposes.
22412241
*
22422242
* @param seed A number that will be used to initialize a new Randomizer.
@@ -2267,7 +2267,7 @@ object Randomizer {
22672267
val buf = ArrayBuffer.empty[T]
22682268
buf ++= xs
22692269

2270-
def swap(i: Int, j: Int) {
2270+
def swap(i: Int, j: Int): Unit = {
22712271
val tmp = buf(i)
22722272
buf(i) = buf(j)
22732273
buf(j) = tmp

project/GenAnyVals.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ object GenAnyVals {
2929
val macroCode =
3030
if (dotty)
3131
s"""
32-
| def apply(value: Expr[$primitiveTypeName])(implicit refl: Reflection): Expr[$typeName] = {
32+
| def apply(value: Expr[$primitiveTypeName])(implicit qctx: QuoteContext): Expr[$typeName] = {
3333
| val notValidMsg = Resources.notValid$typeName
3434
| val notLiteralMsg = Resources.notLiteral$typeName
35-
| import refl._
35+
| import qctx.tasty._
3636
| ensureValid${primitiveTypeName}Literal(value, notValidMsg, notLiteralMsg)(isValid)
3737
| '{ $typeName.ensuringValid($$value) }
3838
| }
@@ -650,9 +650,7 @@ object GenAnyVals {
650650

651651
def importsForMacro(dotty: Boolean): String =
652652
if (dotty)
653-
"""import scala.quoted._
654-
|import scala.tasty._
655-
""".stripMargin
653+
"import scala.quoted._"
656654
else
657655
"import reflect.macros.Context"
658656

project/GenFactoriesDotty.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import org.scalatest.matchers.AMatcher
4646
import org.scalatest.matchers.AnMatcher
4747
import org.scalatest.matchers.MatchPatternMacro
4848
import org.scalatest.matchers.TypeMatcherMacro
49+
import org.scalatest.matchers.MatchPatternHelper
4950
import org.scalatest.matchers.dsl.FullyMatchWord
5051
import org.scalatest.matchers.dsl.StartWithWord
5152
import org.scalatest.matchers.dsl.EndWithWord
@@ -2868,7 +2869,6 @@ object MatcherFactory$arity$ {
28682869
28692870
import scala.language.implicitConversions
28702871
import scala.quoted._
2871-
import scala.tasty._
28722872
28732873
/**
28742874
* Converts a <code>MatcherFactory$arity$</code> to a <code>Matcher</code>.
@@ -2882,7 +2882,7 @@ object MatcherFactory$arity$ {
28822882
/**
28832883
* This method is called by macro that supports 'and not a [Type]' syntax.
28842884
*/
2885-
def andNotATypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#AndNotWord], aType: Expr[ResultOfATypeInvocation[_]])(implicit refl: Reflection, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
2885+
def andNotATypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#AndNotWord], aType: Expr[ResultOfATypeInvocation[_]])(implicit qctx: QuoteContext, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
28862886
val rhs = TypeMatcherMacro.notATypeMatcher(aType)
28872887
28882888
'{ (\$self).owner.and(\$rhs) }
@@ -2891,33 +2891,33 @@ object MatcherFactory$arity$ {
28912891
/**
28922892
* This method is called by macro that supports 'or not a [Type]' syntax.
28932893
*/
2894-
def orNotATypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#OrNotWord], aType: Expr[ResultOfATypeInvocation[_]])(implicit refl: Reflection, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
2894+
def orNotATypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#OrNotWord], aType: Expr[ResultOfATypeInvocation[_]])(implicit qctx: QuoteContext, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
28952895
val rhs = TypeMatcherMacro.notATypeMatcher(aType)
28962896
'{ (\$self).owner.or(\$rhs) }
28972897
}
28982898
28992899
/**
29002900
* This method is called by macro that supports 'and not a [Type]' syntax.
29012901
*/
2902-
def andNotAnTypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#AndNotWord], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit refl: Reflection, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
2902+
def andNotAnTypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#AndNotWord], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit qctx: QuoteContext, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
29032903
val rhs = TypeMatcherMacro.notAnTypeMatcher(anType)
29042904
'{ (\$self).owner.and(\$rhs) }
29052905
}
29062906
29072907
/**
29082908
* This method is called by macro that supports 'or not a [Type]' syntax.
29092909
*/
2910-
def orNotAnTypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#OrNotWord], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit refl: Reflection, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
2910+
def orNotAnTypeMatcherFactory$arity$[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#OrNotWord], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit qctx: QuoteContext, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
29112911
val rhs = TypeMatcherMacro.notAnTypeMatcher(anType)
29122912
'{ (\$self).owner.or(\$rhs) }
29132913
}
29142914
2915-
def andNotMatchPattern[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#AndNotWord], right: Expr[PartialFunction[Any, _]])(implicit refl: Reflection, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
2915+
def andNotMatchPattern[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#AndNotWord], right: Expr[PartialFunction[Any, _]])(implicit qctx: QuoteContext, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
29162916
val notMatcher = '{ MatchPatternHelper.notMatchPatternMatcher(\$right) }
29172917
'{ (\$self).owner.and(\$notMatcher) }
29182918
}
29192919
2920-
def orNotMatchPattern[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#OrNotWord], right: Expr[PartialFunction[Any, _]])(implicit refl: Reflection, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
2920+
def orNotMatchPattern[SC: Type, $typeConstructors$](self: Expr[MatcherFactory$arity$[SC & AnyRef, $commaSeparatedTCNs$]#OrNotWord], right: Expr[PartialFunction[Any, _]])(implicit qctx: QuoteContext, $typeConstructorsWithType$): Expr[MatcherFactory$arity$[SC with AnyRef, $commaSeparatedTCNs$]] = {
29212921
val notMatcher = '{ MatchPatternHelper.notMatchPatternMatcher(\$right) }
29222922
'{ (\$self).owner.or(\$notMatcher) }
29232923
}

project/GenMatchers.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@ object GenMatchers {
152152
targetDir.mkdirs()
153153
val matchersDir = new File(targetDir, "matchers")
154154
matchersDir.mkdirs()
155-
val junitDir = new File(targetDir, "junit")
156-
junitDir.mkdirs()
157-
155+
val shouldDir = new File(matchersDir, "should")
156+
shouldDir.mkdirs()
157+
val mustDir = new File(matchersDir, "must")
158+
mustDir.mkdirs()
158159
Seq(
159-
translateFile(targetDir, "Matchers.scala", "scalatest/src/main/scala/org/scalatest/matchers/should/Matchers.scala", scalaVersion, scalaJS, dotty, translateShouldToMust)
160+
translateFile(mustDir, "Matchers.scala", "scalatest/src/main/scala/org/scalatest/matchers/should/Matchers.scala", scalaVersion, scalaJS, dotty, translateShouldToMust)
160161
/*translateFile(targetDir, "WillMatchers.scala", "scalatest/src/main/scala/org/scalatest/Matchers.scala", scalaVersion, scalaJS, translateShouldToWill)
161162
translateFile(targetDir, "FactNoExceptionWord.scala", "scalatest/src/main/scala/org/scalatest/words/NoExceptionWord.scala", scalaVersion, scalaJS, translateShouldToWill)
162163
translateFile(targetDir, "FactResultOfATypeInvocation.scala", "scalatest/src/main/scala/org/scalatest/words/ResultOfATypeInvocation.scala", scalaVersion, scalaJS,

project/GenResources.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,16 @@ trait GenResourcesJVM extends GenResources {
158158
if (paramCount > 0)
159159
"def " + kv.key + "(" + (for (i <- 0 until paramCount) yield s"param$i: Any").mkString(", ") + "): String = makeString(\"" + kv.key + "\", Array(" + (for (i <- 0 until paramCount) yield s"param$i").mkString(", ") + "))"
160160
else
161-
"def " + kv.key + "(): String = resourceBundle.getString(\"" + kv.key + "\")"
161+
"def " + kv.key + ": String = resourceBundle.getString(\"" + kv.key + "\")"
162162
) + "\n\n" +
163163
"def raw" + kv.key.capitalize + ": String = resourceBundle.getString(\"" + kv.key + "\")"
164164

165-
def failureMessagesKeyValueTemplate(kv: KeyValue, paramCount: Int): String =
166-
"def " + kv.key + (if (paramCount == 0) "(" else "(prettifier: org.scalactic.Prettifier, ") + (for (i <- 0 until paramCount) yield s"param$i: Any").mkString(", ") + "): String = Resources." + kv.key + "(" + (for (i <- 0 until paramCount) yield s"prettifier.apply(param$i)").mkString(", ") + ")"
165+
def failureMessagesKeyValueTemplate(kv: KeyValue, paramCount: Int): String = {
166+
if (paramCount == 0)
167+
"def " + kv.key + ": String = Resources." + kv.key
168+
else
169+
"def " + kv.key + "(prettifier: org.scalactic.Prettifier, " + (for (i <- 0 until paramCount) yield s"param$i: Any").mkString(", ") + "): String = Resources." + kv.key + "(" + (for (i <- 0 until paramCount) yield s"prettifier.apply(param$i)").mkString(", ") + ")"
170+
}
167171

168172
}
169173

project/GenScalaTestDotty.scala

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ object GenScalaTestDotty {
144144
) ++
145145
copyDir("scalatest/src/main/scala/org/scalatest/compatible", "org/scalatest/compatible", targetDir, List.empty) ++
146146
copyDir("scalatest/src/main/scala/org/scalatest/concurrent", "org/scalatest/concurrent", targetDir, List.empty) ++
147+
copyDir("scalatest/src/main/scala/org/scalatest/diagrams", "org/scalatest/diagrams", targetDir,
148+
List(
149+
"Diagrams.scala",
150+
"DiagramsMacro.scala"
151+
)
152+
) ++
147153
copyDir("scalatest/src/main/scala/org/scalatest/exceptions", "org/scalatest/exceptions", targetDir, List.empty) ++
148154
copyDir("scalatest/src/main/scala/org/scalatest/enablers", "org/scalatest/enablers", targetDir, List.empty) ++
149155
copyDir("scalatest/src/main/scala/org/scalatest/events", "org/scalatest/events", targetDir, List.empty) ++
@@ -160,34 +166,44 @@ object GenScalaTestDotty {
160166
"TypeMatcherMacro.scala" // Re-implemented with new macro
161167
)
162168
) ++
169+
copyDir("scalatest/src/main/scala/org/scalatest/matchers/dsl", "org/scalatest/matchers/dsl", targetDir,
170+
List(
171+
"BeWord.scala",
172+
"JavaCollectionWrapper.scala",
173+
"JavaMapWrapper.scala",
174+
"MatchPatternWord.scala",
175+
"NotWord.scala",
176+
"ResultOfNotWordForAny.scala"
177+
)
178+
) ++
179+
copyDir("scalatest/src/main/scala/org/scalatest/matchers/should", "org/scalatest/matchers/should", targetDir, List.empty) ++
163180
copyDir("scalatest/src/main/scala/org/scalatest/path", "org/scalatest/path", targetDir, List.empty) ++
164181
copyDir("scalatest/src/main/scala/org/scalatest/prop", "org/scalatest/prop", targetDir, List.empty) ++
165182
copyDir("scalatest/src/main/scala/org/scalatest/propspec", "org/scalatest/propspec", targetDir, List.empty) ++
166183
copyDir("scalatest/src/main/scala/org/scalatest/time", "org/scalatest/time", targetDir, List.empty) ++
184+
copyDir("scalatest/src/main/scala/org/scalatest/verbs", "org/scalatest/verbs", targetDir, List.empty) ++
167185
copyDir("scalatest/src/main/scala/org/scalatest/tools", "org/scalatest/tools", targetDir, List.empty) ++
168186
copyDir("scalatest/src/main/scala/org/scalatest/refspec", "org/scalatest/refspec", targetDir, List.empty) ++
169-
copyDir("scalatest/src/main/scala/org/scalatest/words", "org/scalatest/words", targetDir,
170-
List(
171-
"BeWord.scala",
172-
"MatchPatternWord.scala",
173-
"NotWord.scala",
174-
"ResultOfNotWordForAny.scala"
175-
)
176-
) ++
187+
copyDir("scalatest/src/main/scala/org/scalatest/words", "org/scalatest/words", targetDir, List.empty) ++
177188
copyDir("scalatest/src/main/scala/org/scalatest/wordspec", "org/scalatest/wordspec", targetDir, List.empty)
178189
}
179190

180191
def genTest(targetDir: File, version: String, scalaVersion: String): Seq[File] = {
181192
copyFiles("scalatest-test/src/test/scala/org/scalatest", "org/scalatest", targetDir,
182193
List(
183194
"AssertionsSpec.scala",
184-
"DiagrammedAssertionsSpec.scala",
185-
"ExpectationsSpec.scala",
186195
"ShouldCompileSpec.scala",
187-
"ShouldNotCompileSpec.scala",
188-
"ShouldNotTypeCheckSpec.scala"
196+
"ShouldNotCompileSpec.scala"/*,
197+
"ShouldNotTypeCheckSpec.scala"*/
198+
)
199+
) ++
200+
copyDir("scalatest-test/src/test/scala/org/scalatest/diagrams", "org/scalatest/diagrams", targetDir, List.empty) ++
201+
copyDir("scalatest-test/src/test/scala/org/scalatest/expectations", "org/scalatest/expectations", targetDir,
202+
List(
203+
"DirectExpectationsSpec.scala"
189204
)
190-
) /*++
205+
)
206+
/*++
191207
copyDir("scalatest-test/src/test/scala/org/scalatest/concurrent", "org/scalatest/concurrent", targetDir,
192208
List(
193209
"WaitersSpec.scala", // skipped because Waiters not supported.

project/scalatest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,8 +2219,8 @@ object ScalatestBuild {
22192219
name.value)
22202220

22212221
// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.14/
2222-
lazy val dottyVersion = dottyLatestNightlyBuild.get
2223-
// lazy val dottyVersion = "0.15.0-bin-20190522-ffb250d-NIGHTLY"
2222+
// lazy val dottyVersion = dottyLatestNightlyBuild.get
2223+
lazy val dottyVersion = "0.17.0-RC1"
22242224
lazy val dottySettings = List(
22252225
scalaVersion := dottyVersion,
22262226
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value)),

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.scalactic
1717

1818
import scala.quoted._
19-
import scala.tasty._
2019

2120
object BooleanMacro {
2221
private val logicOperators = Set("&&", "||", "&", "|")
@@ -38,11 +37,11 @@ object BooleanMacro {
3837
"ne",
3938
"exists") ++ logicOperators
4039

41-
def parse(condition: Expr[Boolean], prettifier: Expr[Prettifier])(implicit refl: Reflection): Expr[Bool] = {
42-
import refl._
40+
def parse(condition: Expr[Boolean], prettifier: Expr[Prettifier])(implicit qctx: QuoteContext): Expr[Bool] = {
41+
import qctx.tasty._
4342
import util._
4443

45-
def exprStr: String = condition.show(the[Context].withoutColors)
44+
def exprStr: String = condition.show
4645
def defaultCase = '{ Bool.simpleMacroBool($condition, ${exprStr.toExpr}, $prettifier) }
4746
def isImplicitMethodType(tp: Type): Boolean =
4847
Type.IsMethodType.unapply(tp).flatMap(tp => if tp.isImplicit then Some(true) else None).nonEmpty
@@ -229,7 +228,7 @@ object BooleanMacro {
229228
case TypeApply(sel @ Select(lhs, "isInstanceOf"), targs) =>
230229
let(lhs) { l =>
231230
val res = l.select(sel.symbol).appliedToTypeTrees(targs).seal.cast[Boolean]
232-
val name = targs.head.tpe.show(the[Context].withoutColors).toExpr
231+
val name = targs.head.tpe.show.toExpr
233232
'{ Bool.isInstanceOfMacroBool(${l.seal}, "isInstanceOf", $name, $res, $prettifier) }.unseal
234233
}.seal.cast[Bool]
235234

0 commit comments

Comments
 (0)