File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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()
You can’t perform that action at this time.
0 commit comments