-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6541 from dotty-staging/fix-#6535
Fix #6535: Add missing span
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import scala.quoted._ | ||
import scala.tasty._ | ||
|
||
object scalatest { | ||
|
||
inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) } | ||
|
||
def assertImpl(cond: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { | ||
import refl._ | ||
import util._ | ||
|
||
cond.unseal.underlyingArgument match { | ||
case t @ Apply(Select(lhs, op), rhs :: Nil) => | ||
let(lhs) { left => | ||
let(rhs) { right => | ||
val app = Select.overloaded(left, op, Nil, right :: Nil) | ||
let(app) { result => | ||
val l = left.seal | ||
val r = right.seal | ||
val b = result.seal.cast[Boolean] | ||
val code = '{ scala.Predef.assert($b) } | ||
code.unseal | ||
} | ||
} | ||
}.seal.cast[Unit] | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
object Test { | ||
import scalatest._ | ||
|
||
def neverRuns(f: => Unit): Boolean = true | ||
|
||
def main(args: Array[String]): Unit = { | ||
assert(this.neverRuns(sys.error("Sad times 1"))) | ||
} | ||
} |