Skip to content

Commit 453591f

Browse files
Merge pull request #8120 from dotty-staging/fix-#6803
Fix #6803: Add regression test
2 parents cc04eaf + 331b830 commit 453591f

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/run-macros/i6803/Macro_1.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package blah
2+
3+
import scala.language.implicitConversions
4+
import scala.quoted._
5+
6+
object AsObject {
7+
final class LineNo(val lineNo: Int)
8+
object LineNo {
9+
def unsafe(i: Int): LineNo = new LineNo(i)
10+
inline given LineNo = ${impl}
11+
private def impl with (qctx: QuoteContext): Expr[LineNo] = {
12+
import qctx.tasty.{given, _}
13+
'{unsafe(${Expr(rootPosition.startLine)})}
14+
}
15+
}
16+
}
17+
18+
package AsPackage {
19+
final class LineNo(val lineNo: Int)
20+
object LineNo {
21+
def unsafe(i: Int): LineNo = new LineNo(i)
22+
inline given LineNo = ${impl}
23+
private def impl with (qctx: QuoteContext): Expr[LineNo] = {
24+
import qctx.tasty.{given, _}
25+
'{unsafe(${Expr(rootPosition.startLine)})}
26+
}
27+
}
28+
}

tests/run-macros/i6803/Test_2.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import blah._
2+
3+
def testO(): Unit = {
4+
import AsObject.LineNo
5+
assert(summon[LineNo].lineNo == 4)
6+
}
7+
8+
def testP(): Unit = {
9+
import AsPackage.LineNo
10+
assert(summon[LineNo].lineNo == 9)
11+
}
12+
13+
@main def Test =
14+
testO()
15+
testP()

0 commit comments

Comments
 (0)