Skip to content

Commit 3b6570c

Browse files
committed
Merge branch 'feature-dotty-0.22.0-RC1' of https://github.com/cheeseng/scalatest into cheeseng-feature-dotty-0.22.0-RC1
2 parents 8523b4c + 598bba3 commit 3b6570c

File tree

11 files changed

+42
-42
lines changed

11 files changed

+42
-42
lines changed

project/DottyBuild.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait DottyBuild { this: BuildCommons =>
1313

1414
// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.14/
1515
// lazy val dottyVersion = dottyLatestNightlyBuild.get
16-
lazy val dottyVersion = "0.21.0-RC1"
16+
lazy val dottyVersion = "0.22.0-RC1"
1717
lazy val dottySettings = List(
1818
scalaVersion := dottyVersion,
1919
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value)),
@@ -713,4 +713,4 @@ trait DottyBuild { this: BuildCommons =>
713713
publishLocal := {}
714714
).dependsOn(scalatestDotty % "test", commonTestDotty % "test")
715715

716-
}
716+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object BooleanMacro {
4444
def exprStr: String = condition.show
4545
def defaultCase = '{ Bool.simpleMacroBool($condition, ${Expr(exprStr)}, $prettifier) }
4646
def isImplicitMethodType(tp: Type): Boolean = tp match {
47-
case IsMethodType(tp) => tp.isImplicit
47+
case tp: MethodType => tp.isImplicit
4848
case _ => false
4949
}
5050

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ trait Requirements {
143143
* @param condition the boolean condition to check as requirement
144144
* @throws IllegalArgumentException if the condition is <code>false</code>.
145145
*/
146-
inline def require(condition: => Boolean)(implicit prettifier: Prettifier): Unit =
146+
inline def require(inline condition: Boolean)(implicit prettifier: Prettifier): Unit =
147147
${ RequirementsMacro.require('{condition}, '{prettifier}, '{""}) }
148148

149149
/**
@@ -161,7 +161,7 @@ trait Requirements {
161161
* @throws IllegalArgumentException if the condition is <code>false</code>.
162162
* @throws NullPointerException if <code>message</code> is <code>null</code>.
163163
*/
164-
inline def require(condition: => Boolean, clue: Any)(implicit prettifier: Prettifier): Unit =
164+
inline def require(inline condition: Boolean, clue: Any)(implicit prettifier: Prettifier): Unit =
165165
${ RequirementsMacro.require('{condition}, '{prettifier}, '{clue}) }
166166

167167
/**
@@ -179,7 +179,7 @@ trait Requirements {
179179
* @param condition the boolean condition to check as requirement
180180
* @throws IllegalStateException if the condition is <code>false</code>.
181181
*/
182-
inline def requireState(condition: => Boolean)(implicit prettifier: Prettifier): Unit =
182+
inline def requireState(inline condition: Boolean)(implicit prettifier: Prettifier): Unit =
183183
${ RequirementsMacro.requireState('{condition}, '{prettifier}, '{""}) }
184184

185185
/**
@@ -199,7 +199,7 @@ trait Requirements {
199199
* @throws IllegalStateException if the condition is <code>false</code>.
200200
* @throws NullPointerException if <code>message</code> is <code>null</code>.
201201
*/
202-
inline def requireState(condition: => Boolean, clue: Any)(implicit prettifier: Prettifier): Unit =
202+
inline def requireState(inline condition: Boolean, clue: Any)(implicit prettifier: Prettifier): Unit =
203203
${ RequirementsMacro.requireState('{condition}, '{prettifier}, '{clue}) }
204204

205205
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,7 @@ object NumericString {
27112711
* a valid <code>String</code> literal, the invocation of this method
27122712
* will not compile.)
27132713
*/
2714-
inline def apply(value: => String): NumericString = ${ NumericStringMacro('{value}) }
2714+
inline def apply(inline value: String): NumericString = ${ NumericStringMacro('{value}) }
27152715

27162716
/**
27172717
* A factory/validation method that produces a <code>NumericString</code>,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ object PercentageInt {
3030
throw new AssertionError(s"$value was not a valid PercentageInt")
3131
}
3232

33-
inline def apply(value: => Int): PercentageInt = ${ PercentageIntMacro('{value}) }
33+
inline def apply(inline value: Int): PercentageInt = ${ PercentageIntMacro('{value}) }
3434
}
3535

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,6 @@ private[scalactic] object RegexString {
188188
def fromOrElse(value: String, default: => RegexString): RegexString =
189189
if (RegexStringMacro.isValid(value)) new RegexString(value) else default
190190

191-
inline def apply(value: => String): RegexString = ${ RegexStringMacro('{value}) }
191+
inline def apply(inline value: String): RegexString = ${ RegexStringMacro('{value}) }
192192
}
193193

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ trait Assertions extends TripleEquals {
467467
* @param condition the boolean condition to assert
468468
* @throws TestFailedException if the condition is <code>false</code>.
469469
*/
470-
inline def assert(condition: => Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
470+
inline def assert(inline condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
471471
${ AssertionsMacro.assert('{condition}, '{prettifier}, '{pos}, '{""}) }
472472

473473
private[scalatest] def newAssertionFailedException(optionalMessage: Option[String], optionalCause: Option[Throwable], pos: source.Position, analysis: scala.collection.immutable.IndexedSeq[String]): Throwable =
@@ -526,7 +526,7 @@ trait Assertions extends TripleEquals {
526526
* @throws TestFailedException if the condition is <code>false</code>.
527527
* @throws NullArgumentException if <code>message</code> is <code>null</code>.
528528
*/
529-
inline def assert(condition: => Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
529+
inline def assert(inline condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
530530
${ AssertionsMacro.assert('{condition}, '{prettifier}, '{pos}, '{clue}) }
531531

532532
/**
@@ -574,7 +574,7 @@ trait Assertions extends TripleEquals {
574574
* @param condition the boolean condition to assume
575575
* @throws TestCanceledException if the condition is <code>false</code>.
576576
*/
577-
inline def assume(condition: => Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
577+
inline def assume(inline condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
578578
${ AssertionsMacro.assume('{condition}, '{prettifier}, '{pos}, '{""}) }
579579

580580
/**
@@ -627,7 +627,7 @@ trait Assertions extends TripleEquals {
627627
* @throws TestCanceledException if the condition is <code>false</code>.
628628
* @throws NullArgumentException if <code>message</code> is <code>null</code>.
629629
*/
630-
inline def assume(condition: => Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
630+
inline def assume(inline condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
631631
${ AssertionsMacro.assume('{condition}, '{prettifier}, '{pos}, '{clue}) }
632632

633633
/**
@@ -661,7 +661,7 @@ trait Assertions extends TripleEquals {
661661
* @param code the snippet of code that should not type check
662662
*/
663663
inline def assertTypeError(inline code: String)(implicit pos: source.Position): Assertion =
664-
${ CompileMacro.assertTypeErrorImpl('code, typeChecks(code), '{ pos }) }
664+
${ CompileMacro.assertTypeErrorImpl('code, '{typeChecks(code)}, '{ pos }) }
665665

666666
/**
667667
* Asserts that a given string snippet of code does not pass either the Scala parser or type checker.
@@ -693,7 +693,7 @@ trait Assertions extends TripleEquals {
693693
* @param code the snippet of code that should not type check
694694
*/
695695
inline def assertDoesNotCompile(inline code: String)(implicit pos: source.Position): Assertion =
696-
${ CompileMacro.assertDoesNotCompileImpl('code, typeChecks(code), 'pos) }
696+
${ CompileMacro.assertDoesNotCompileImpl('code, '{typeChecks(code)}, 'pos) }
697697

698698
/**
699699
* Asserts that a given string snippet of code passes both the Scala parser and type checker.
@@ -715,7 +715,7 @@ trait Assertions extends TripleEquals {
715715
* @param code the snippet of code that should compile
716716
*/
717717
inline def assertCompiles(inline code: String)(implicit pos: source.Position): Assertion =
718-
${ CompileMacro.assertCompilesImpl('code, typeChecks(code), 'pos) }
718+
${ CompileMacro.assertCompilesImpl('code, '{typeChecks(code)}, 'pos) }
719719

720720
/**
721721
* Intercept and return an exception that's expected to

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ import scala.quoted._
2424
object CompileMacro {
2525

2626
// parse and type check a code snippet, generate code to throw TestFailedException when type check passes or parse error
27-
def assertTypeErrorImpl(code: Expr[String], typeChecked: Boolean, pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Assertion] = {
27+
def assertTypeErrorImpl(code: Expr[String], typeChecked: Expr[Boolean], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Assertion] = {
2828
import qctx.tasty.{_, given}
2929

30-
if (!typeChecked) '{ Succeeded }
30+
if (!typeChecked.value) '{ Succeeded }
3131
else '{
3232
val messageExpr = Resources.expectedTypeErrorButGotNone($code)
3333
throw new TestFailedException((_: StackDepthException) => Some(messageExpr), None, $pos)
3434
}
3535
}
3636

37-
def expectTypeErrorImpl(code: Expr[String], typeChecked: Boolean, prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Fact] = {
37+
def expectTypeErrorImpl(code: Expr[String], typeChecked: Expr[Boolean], prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Fact] = {
3838
import qctx.tasty.{_, given}
3939

40-
if (typeChecked)
40+
if (typeChecked.value)
4141
'{
4242
val messageExpr = Resources.expectedTypeErrorButGotNone($code)
4343
Fact.No(
@@ -69,21 +69,21 @@ object CompileMacro {
6969
}
7070

7171
// parse and type check a code snippet, generate code to throw TestFailedException when both parse and type check succeeded
72-
def assertDoesNotCompileImpl(code: Expr[String], typeChecked: Boolean, pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Assertion] = {
72+
def assertDoesNotCompileImpl(code: Expr[String], typeChecked: Expr[Boolean], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Assertion] = {
7373
import qctx.tasty.{_, given}
7474

75-
if (!typeChecked) '{ Succeeded }
75+
if (!typeChecked.value) '{ Succeeded }
7676
else '{
7777
val messageExpr = Resources.expectedCompileErrorButGotNone($code)
7878
throw new TestFailedException((_: StackDepthException) => Some(messageExpr), None, $pos)
7979
}
8080
}
8181

8282
// parse and type check a code snippet, generate code to return Fact (Yes or No).
83-
def expectDoesNotCompileImpl(code: Expr[String], typeChecked: Boolean, prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Fact] = {
83+
def expectDoesNotCompileImpl(code: Expr[String], typeChecked: Expr[Boolean], prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Fact] = {
8484
import qctx.tasty.{_, given}
8585

86-
if (typeChecked)
86+
if (typeChecked.value)
8787
'{
8888
val messageExpr = Resources.expectedCompileErrorButGotNone($code)
8989
Fact.No(
@@ -115,20 +115,20 @@ object CompileMacro {
115115
}
116116

117117
// parse and type check a code snippet, generate code to throw TestFailedException when either parse or type check fails.
118-
def assertCompilesImpl(code: Expr[String], typeChecked: Boolean, pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Assertion] = {
118+
def assertCompilesImpl(code: Expr[String], typeChecked: Expr[Boolean], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Assertion] = {
119119
import qctx.tasty.{_, given}
120120

121-
if (typeChecked) '{ Succeeded }
121+
if (typeChecked.value) '{ Succeeded }
122122
else '{
123123
val messageExpr = Resources.expectedNoErrorButGotTypeError("unknown", $code)
124124
throw new TestFailedException((_: StackDepthException) => Some(messageExpr), None, $pos)
125125
}
126126
}
127127

128-
def expectCompilesImpl(code: Expr[String], typeChecked: Boolean, prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Fact] = {
128+
def expectCompilesImpl(code: Expr[String], typeChecked: Expr[Boolean], prettifier: Expr[Prettifier], pos: Expr[source.Position])(implicit qctx: QuoteContext): Expr[Fact] = {
129129
import qctx.tasty.{_, given}
130130

131-
if (typeChecked)
131+
if (typeChecked.value)
132132
'{
133133
val messageExpr = Resources.compiledSuccessfully($code)
134134
Fact.Yes(

scalatest.dotty/src/main/scala/org/scalatest/diagrams/Diagrams.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ trait Diagrams extends Assertions {
177177
* @param condition the boolean condition to assert
178178
* @throws TestFailedException if the condition is <code>false</code>.
179179
*/
180-
inline override def assert(condition: => Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
180+
inline override def assert(inline condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
181181
${ DiagrammedAssertionsMacro.assert('{condition}, '{prettifier}, '{pos}, '{""}) }
182182

183183
/**
@@ -199,7 +199,7 @@ trait Diagrams extends Assertions {
199199
* @throws TestFailedException if the condition is <code>false</code>.
200200
* @throws NullArgumentException if <code>message</code> is <code>null</code>.
201201
*/
202-
inline override def assert(condition: => Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
202+
inline override def assert(inline condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
203203
${ DiagrammedAssertionsMacro.assert('condition, 'prettifier, 'pos, 'clue) }
204204

205205
/**
@@ -220,7 +220,7 @@ trait Diagrams extends Assertions {
220220
* @param condition the boolean condition to assume
221221
* @throws TestCanceledException if the condition is <code>false</code>.
222222
*/
223-
inline override def assume(condition: => Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
223+
inline override def assume(inline condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
224224
${ DiagrammedAssertionsMacro.assume('condition, 'prettifier, 'pos, '{""}) }
225225

226226
/**
@@ -242,7 +242,7 @@ trait Diagrams extends Assertions {
242242
* @throws TestCanceledException if the condition is <code>false</code>.
243243
* @throws NullArgumentException if <code>message</code> is <code>null</code>.
244244
*/
245-
inline override def assume(condition: => Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
245+
inline override def assume(inline condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
246246
${ DiagrammedAssertionsMacro.assume('condition, 'prettifier, 'pos, 'clue) }
247247
}
248248

scalatest.dotty/src/main/scala/org/scalatest/diagrams/DiagramsMacro.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object DiagramsMacro {
3333
def isXmlSugar(apply: Apply): Boolean = apply.tpe <:< typeOf[scala.xml.Elem]
3434
def isJavaStatic(tree: Tree): Boolean = tree.symbol.flags.is(Flags.Static)
3535
def isImplicitMethodType(tp: Type): Boolean = tp match {
36-
case IsMethodType(tp) => tp.isImplicit
36+
case tp: MethodType => tp.isImplicit
3737
case _ => false
3838
}
3939

@@ -74,15 +74,15 @@ object DiagramsMacro {
7474
expr match {
7575
case Apply(Select(New(_), _), _) => default(expr)
7676

77-
case IsApply(apply) if isXmlSugar(apply) => default(expr)
77+
case apply: Apply if isXmlSugar(apply) => default(expr)
7878

79-
case IsApply(apply) if isJavaStatic(apply) => default(expr)
79+
case apply: Apply if isJavaStatic(apply) => default(expr)
8080

8181
case Select(This(_), _) => default(expr)
8282

83-
case IsSelect(x) if x.symbol.flags.is(Flags.Object) => default(expr)
83+
case x: Select if x.symbol.flags.is(Flags.Object) => default(expr)
8484

85-
case IsSelect(x) if isJavaStatic(x) => default(expr)
85+
case x: Select if isJavaStatic(x) => default(expr)
8686

8787
case sel @ Select(qual, name) =>
8888
type T
@@ -229,4 +229,4 @@ object DiagramsMacro {
229229
val diagExpr = parse(qctx)(condition.unseal.underlyingArgument).seal.cast[DiagrammedExpr[Boolean]]
230230
'{ $helper($diagExpr, $clue, ${Expr(sourceText)}, $pos) }
231231
}
232-
}
232+
}

0 commit comments

Comments
 (0)