Skip to content

Commit 5987fb2

Browse files
committed
Get dotty build to compile without errors, still have some failing tests in scalatest.
1 parent 8c143d0 commit 5987fb2

13 files changed

+73
-50
lines changed

project/GenFactoriesDotty.scala

Lines changed: 1 addition & 0 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

project/GenMatchers.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,17 @@ 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()
155+
val shouldDir = new File(matchersDir, "should")
156+
shouldDir.mkdirs()
157+
val mustDir = new File(matchersDir, "must")
158+
mustDir.mkdirs()
157159

160+
(if (scalaJS || dotty)
161+
Seq(translateFile(shouldDir, "Matchers.scala", "scalatest/src/main/scala/org/scalatest/matchers/should/Matchers.scala", scalaVersion, scalaJS, dotty, line => line))
162+
else
163+
Seq.empty[File]) ++
158164
Seq(
159-
translateFile(targetDir, "Matchers.scala", "scalatest/src/main/scala/org/scalatest/matchers/should/Matchers.scala", scalaVersion, scalaJS, dotty, translateShouldToMust)
165+
translateFile(mustDir, "Matchers.scala", "scalatest/src/main/scala/org/scalatest/matchers/should/Matchers.scala", scalaVersion, scalaJS, dotty, translateShouldToMust)
160166
/*translateFile(targetDir, "WillMatchers.scala", "scalatest/src/main/scala/org/scalatest/Matchers.scala", scalaVersion, scalaJS, translateShouldToWill)
161167
translateFile(targetDir, "FactNoExceptionWord.scala", "scalatest/src/main/scala/org/scalatest/words/NoExceptionWord.scala", scalaVersion, scalaJS, translateShouldToWill)
162168
translateFile(targetDir, "FactResultOfATypeInvocation.scala", "scalatest/src/main/scala/org/scalatest/words/ResultOfATypeInvocation.scala", scalaVersion, scalaJS,

project/GenScalaTestDotty.scala

Lines changed: 19 additions & 8 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,20 +166,25 @@ 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

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package org.scalatest
1717

1818
import org.scalactic._
1919
import scala.quoted._
20+
import org.scalatest.diagrams._
2021

2122
object DiagrammedAssertionsMacro {
2223
/**
@@ -35,21 +36,21 @@ object DiagrammedAssertionsMacro {
3536
val endLine = rootPosition.endLine // Get the expression last line number
3637

3738
if (startLine == endLine) // Only use diagram macro if it is one line, where startLine will be equaled to endLine
38-
DiagrammedExprMacro.transform(helper, condition, pos, clue, rootPosition.sourceCode)
39+
DiagramsMacro.transform(helper, condition, pos, clue, rootPosition.sourceCode)
3940
else // otherwise we'll just fallback to use BooleanMacro
4041
AssertionsMacro.transform(fallback, condition, prettifier, pos, clue)
4142
}
4243

4344
def assert(condition: Expr[Boolean], prettifier: Expr[Prettifier], pos: Expr[source.Position], clue: Expr[Any])(implicit qctx: QuoteContext): Expr[Assertion] = {
4445
macroImpl(
45-
'{ DiagrammedAssertions.diagrammedAssertionsHelper.macroAssert },
46+
'{ Diagrams.diagrammedAssertionsHelper.macroAssert },
4647
'{ Assertions.assertionsHelper.macroAssert },
4748
condition, clue, prettifier, pos)
4849
}
4950

5051
def assume(condition: Expr[Boolean], prettifier: Expr[Prettifier], pos: Expr[source.Position], clue: Expr[Any])(implicit qctx: QuoteContext): Expr[Assertion] = {
5152
macroImpl(
52-
'{ DiagrammedAssertions.diagrammedAssertionsHelper.macroAssume },
53+
'{ Diagrams.diagrammedAssertionsHelper.macroAssume },
5354
'{ Assertions.assertionsHelper.macroAssume },
5455
condition, clue, prettifier, pos)
5556
}

scalatest.dotty/src/main/scala/org/scalatest/DiagrammedAssertions.scala renamed to scalatest.dotty/src/main/scala/org/scalatest/diagrams/Diagrams.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.scalatest
16+
package org.scalatest.diagrams
1717

1818
import org.scalactic._
1919
import org.scalactic.Requirements._
2020
import scala.collection.mutable.ListBuffer
2121
import collection.immutable.TreeMap
22+
import org.scalatest.{AnchorValue, Assertions, DiagrammedExpr, DiagrammedAssertionsMacro, Succeeded}
23+
import org.scalatest.compatible.Assertion
2224

2325
/**
2426
* Sub-trait of <code>Assertions</code> that override <code>assert</code> and <code>assume</code> methods to include
@@ -152,7 +154,7 @@ import collection.immutable.TreeMap
152154
*
153155
* <p>Trait <code>DiagrammedAssertions</code> was inspired by Peter Niederwieser's work in <a href="http://code.google.com/p/spock/">Spock</a> and <a href="https://github.com/pniederw/expecty">Expecty</a>.
154156
*/
155-
trait DiagrammedAssertions extends Assertions {
157+
trait Diagrams extends Assertions {
156158

157159
import scala.tasty._
158160
import scala.quoted._
@@ -277,7 +279,7 @@ trait DiagrammedAssertions extends Assertions {
277279
* at sun.reflect.NativeMethodAccessorImpl.invoke...
278280
* </pre>
279281
*/
280-
object DiagrammedAssertions extends DiagrammedAssertions {
282+
object Diagrams extends Diagrams {
281283

282284
/**
283285
* Helper class used by code generated by the overriden <code>assert</code> macro.

scalatest.dotty/src/main/scala/org/scalatest/DiagrammedExprMacro.scala renamed to scalatest.dotty/src/main/scala/org/scalatest/diagrams/DiagramsMacro.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.scalatest
16+
package org.scalatest.diagrams
1717

1818
import org.scalactic._
1919
import scala.quoted._
20+
import org.scalatest.{Assertions, DiagrammedExpr}
21+
import org.scalatest.compatible.Assertion
2022

21-
22-
object DiagrammedExprMacro {
23+
object DiagramsMacro {
2324
// Transform the input expression by parsing out the anchor and generate expression that can support diagram rendering
2425
def parse(qctx: QuoteContext)(expr: qctx.tasty.Term): qctx.tasty.Term = {
2526
implicit val qctx2: QuoteContext = qctx

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.scalatest.matchers
1717

1818
import org.scalatest.Resources
19-
import org.scalatest.words.ResultOfNotWordForAny
19+
import org.scalatest.matchers.dsl.ResultOfNotWordForAny
2020
import scala.quoted._
2121
import scala.tasty._
2222

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ package org.scalatest.matchers
1818
import org.scalactic._
1919
import org.scalatest.enablers._
2020
import org.scalatest.words._
21+
import org.scalatest.matchers.dsl._
2122
import org.scalatest.FailureMessages
22-
import org.scalatest.MatchersHelper.andMatchersAndApply
23-
import org.scalatest.MatchersHelper.orMatchersAndApply
23+
import org.scalatest.matchers.MatchersHelper.andMatchersAndApply
24+
import org.scalatest.matchers.MatchersHelper.orMatchersAndApply
2425
import org.scalatest.Resources
2526
import scala.collection.GenTraversable
2627
import scala.reflect.ClassTag

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.scalatest.matchers
1717

18-
import org.scalatest.words.{ResultOfAnTypeInvocation, MatcherWords, ResultOfATypeInvocation, ResultOfNotWordForAny}
18+
import org.scalatest.matchers.dsl.{ResultOfAnTypeInvocation, MatcherWords, ResultOfATypeInvocation, ResultOfNotWordForAny}
1919

2020
// //import org.scalatest.words.{FactResultOfAnTypeInvocation, FactResultOfATypeInvocation}
2121
// import org.scalactic.Prettifier
@@ -24,7 +24,7 @@ import org.scalatest.words.{ResultOfAnTypeInvocation, MatcherWords, ResultOfATyp
2424
import scala.quoted._
2525
import scala.tasty._
2626

27-
private[scalatest] object TypeMatcherMacro {
27+
object TypeMatcherMacro {
2828

2929
// // Check that no type parameter is specified, if any does, give a friendly compiler warning.
3030
def checkTypeParameter(qctx: QuoteContext)(tree: qctx.tasty.Term, methodName: String): Unit = {
@@ -169,7 +169,7 @@ private[scalatest] object TypeMatcherMacro {
169169
}
170170

171171
// Do checking on type parameter and generate AST to call TypeMatcherHelper.checkAType, used by 'shouldBe a [type]' syntax
172-
def shouldBeATypeImpl(self: Expr[org.scalatest.Matchers#AnyShouldWrapper[_]], aType: Expr[ResultOfATypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
172+
def shouldBeATypeImpl(self: Expr[org.scalatest.matchers.should.Matchers#AnyShouldWrapper[_]], aType: Expr[ResultOfATypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
173173
import qctx.tasty._
174174
checkTypeParameter(qctx)(aType.unseal, "a")
175175
'{
@@ -178,7 +178,7 @@ private[scalatest] object TypeMatcherMacro {
178178
}
179179

180180
// Do checking on type parameter and generate AST to call TypeMatcherHelper.checkAType, used by 'mustBe a [type]' syntax
181-
def mustBeATypeImpl(self: Expr[org.scalatest.MustMatchers#AnyMustWrapper[_]], aType: Expr[ResultOfATypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
181+
def mustBeATypeImpl(self: Expr[org.scalatest.matchers.must.Matchers#AnyMustWrapper[_]], aType: Expr[ResultOfATypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
182182
import qctx.tasty._
183183
checkTypeParameter(qctx)(aType.unseal, "a")
184184
'{
@@ -187,7 +187,7 @@ private[scalatest] object TypeMatcherMacro {
187187
}
188188

189189
// Do checking on type parameter and generate AST to call TypeMatcherHelper.checkAType, used by 'shouldBe an [type]' syntax
190-
def shouldBeAnTypeImpl(self: Expr[org.scalatest.Matchers#AnyShouldWrapper[_]], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
190+
def shouldBeAnTypeImpl(self: Expr[org.scalatest.matchers.should.Matchers#AnyShouldWrapper[_]], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
191191
import qctx.tasty._
192192
checkTypeParameter(qctx)(anType.unseal, "an")
193193
'{
@@ -196,7 +196,7 @@ private[scalatest] object TypeMatcherMacro {
196196
}
197197

198198
// Do checking on type parameter and generate AST to call TypeMatcherHelper.checkAnType, used by 'mustBe an [type]' syntax
199-
def mustBeAnTypeImpl(self: Expr[org.scalatest.MustMatchers#AnyMustWrapper[_]], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
199+
def mustBeAnTypeImpl(self: Expr[org.scalatest.matchers.must.Matchers#AnyMustWrapper[_]], anType: Expr[ResultOfAnTypeInvocation[_]])(implicit qctx: QuoteContext): Expr[org.scalatest.Assertion] = {
200200
import qctx.tasty._
201201
checkTypeParameter(qctx)(anType.unseal, "an")
202202
'{

scalatest.dotty/src/main/scala/org/scalatest/words/BeWord.scala renamed to scalatest.dotty/src/main/scala/org/scalatest/matchers/dsl/BeWord.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.scalatest.words
16+
package org.scalatest.matchers.dsl
1717

1818
import org.scalactic._
1919
import org.scalatest.matchers._
@@ -24,7 +24,7 @@ import org.scalatest.Resources
2424
import org.scalatest.Suite
2525
import org.scalatest.UnquotedString
2626
// SKIP-SCALATESTJS,NATIVE-START
27-
import org.scalatest.MatchersHelper.matchSymbolToPredicateMethod
27+
import org.scalatest.matchers.MatchersHelper.matchSymbolToPredicateMethod
2828
// SKIP-SCALATESTJS,NATIVE-END
2929
import org.scalatest.enablers.Definition
3030
import org.scalatest.enablers.Emptiness

0 commit comments

Comments
 (0)