Skip to content

Commit 296222f

Browse files
authored
Merge pull request #6065 from dotty-staging/fix-#5629
Fix #5629: Add regression test
2 parents 51d8cab + 803d869 commit 296222f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/run/i5629/Macro_1.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import scala.quoted._
2+
import scala.tasty._
3+
4+
object Macros {
5+
6+
inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) }
7+
8+
def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = {
9+
import refl._
10+
val b = cond.unseal.underlyingArgument.seal[Boolean]
11+
'{ scala.Predef.assert($b) }
12+
}
13+
14+
inline def thisLineNumber = ${ thisLineNumberImpl }
15+
16+
def thisLineNumberImpl(implicit refl: Reflection): Expr[Int] = {
17+
import refl._
18+
refl.rootPosition.startLine.toExpr
19+
}
20+
}

tests/run/i5629/Test_2.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Test {
2+
import Macros._
3+
4+
def main(args: Array[String]): Unit = {
5+
val startLine = thisLineNumber
6+
assert(thisLineNumber == startLine + 1)
7+
assert(thisLineNumber == startLine + 2)
8+
scala.Predef.assert(thisLineNumber == startLine + 3)
9+
}
10+
}

0 commit comments

Comments
 (0)