File tree Expand file tree Collapse file tree 6 files changed +117
-57
lines changed Expand file tree Collapse file tree 6 files changed +117
-57
lines changed Original file line number Diff line number Diff line change 1- [486..500] in quoted_2.scala
2- here is the the argument is _root_.scala.StringContext.apply(("abc", "": scala.<repeated>[scala#Predef.String])).s(("def": scala.<repeated>[scala.Any]))
3- [453..466] in quoted_2.scala
4- here is the the argument is ("abc": scala.Predef.String)
5- [407..408] in quoted_2.scala
6- here is the the argument is d
7- [386..387] in quoted_2.scala
8- here is the the argument is c
9- [309..323] in quoted_2.scala
10- here is the the argument is _root_.scala.StringContext.apply(("abc", "": scala.<repeated>[scala#Predef.String])).s(("def": scala.<repeated>[scala.Any]))
11- [277..290] in quoted_2.scala
12- here is the the argument is ("abc": scala.Predef.String)
13- [233..234] in quoted_2.scala
14- here is the the argument is d
15- [213..214] in quoted_2.scala
16- here is the the argument is c
1+ [117..120] in quoted_2.scala
2+ here is the the argument is foo
Original file line number Diff line number Diff line change @@ -6,20 +6,10 @@ object Macros {
66
77 inline def fun (x : Any ): Unit = $ { impl(' x ) }
88
9- inline def fun2 (x : => Any ): Unit = $ { impl(' x ) }
10-
11- inline def fun3 [T ]: Unit = $ { impl2(' [T ]) }
12-
139 def impl (x : Expr [Any ])(implicit reflect : Reflection ): Expr [Unit ] = {
1410 import reflect ._
1511 error(" here is the the argument is " + x.unseal.underlyingArgument.showCode, x.unseal.underlyingArgument.pos)
1612 ' {}
1713 }
1814
19- def impl2 [T ](x : quoted.Type [T ])(implicit reflect : Reflection ): Expr [Unit ] = {
20- import reflect ._
21- error(" here is the the argument is " + x.unseal.showCode, x.unseal.pos)
22- ' {}
23- }
24-
2515}
Original file line number Diff line number Diff line change @@ -3,36 +3,9 @@ import Macros._
33
44object Test {
55 def main (args : Array [String ]): Unit = {
6- val a : String = " abc"
7- val b : 42 = 42
8- def c : String = " abc"
9- def d : 42 = 42
10-
11- // fun(a) // ERROR
12- // fun(b) // ERROR
13- fun(c) // error
14- fun(d) // error
15- // fun("abc") // ERROR
16- fun(" abc" : String ) // error
17- fun(s " abc ${" def" }" ) // error
18-
19- // fun2(a) // ERROR
20- // fun2(b) // ERROR
21- fun2(c) // error
22- fun2(d) // error
23- // fun2("abc") // ERROR
24- fun2(" abc" : String ) // error
25- fun2(s " abc ${" def" }" ) // error
26-
27- // type T
28- // type U = "abc"
29- //
30- // fun3[T] // ERROR
31- // fun3[String] // ERROR
32- // fun3["abc"] // ERROR
33- // fun3[U] // ERROR
6+ def foo : String = " abc"
7+ fun(
8+ foo // error
9+ )
3410 }
35- // FIXME all the lines marked as ERROR have the wrong position on the three of the argument.
36- // they all have as source file this file but the span of `'x` in `fun` or `fun2`.
37- // see #6026 and #6027
3811}
Original file line number Diff line number Diff line change 1+ quoted_2.scala:[103..103]
2+ a
3+ quoted_2.scala:[103..103]
4+ b
5+ quoted_2.scala:[213..214]
6+ c
7+ quoted_2.scala:[224..225]
8+ d
9+ quoted_2.scala:[103..103]
10+ "abc"
11+ quoted_2.scala:[259..272]
12+ ("abc": scala.Predef.String)
13+ quoted_2.scala:[282..296]
14+ _root_.scala.StringContext.apply(("abc", "": scala.<repeated>[scala#Predef.String])).s(("def": scala.<repeated>[scala.Any]))
15+ quoted_2.scala:[154..154]
16+ a
17+ quoted_2.scala:[154..154]
18+ b
19+ quoted_2.scala:[350..351]
20+ c
21+ quoted_2.scala:[362..363]
22+ d
23+ quoted_2.scala:[154..154]
24+ "abc"
25+ quoted_2.scala:[399..412]
26+ ("abc": scala.Predef.String)
27+ quoted_2.scala:[423..437]
28+ _root_.scala.StringContext.apply(("abc", "": scala.<repeated>[scala#Predef.String])).s(("def": scala.<repeated>[scala.Any]))
29+ quoted_2.scala:[201..202]
30+ T
31+ quoted_2.scala:[201..202]
32+ scala.Predef.String
33+ quoted_2.scala:[201..202]
34+ "abc"
35+ quoted_2.scala:[201..202]
36+ U
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+
3+ import scala .tasty ._
4+
5+ object Macros {
6+
7+ inline def fun (x : Any ): Unit = $ { impl(' x ) }
8+
9+ inline def fun2 (x : => Any ): Unit = $ { impl(' x ) }
10+
11+ inline def fun3 [T ]: Unit = $ { impl2(' [T ]) }
12+
13+ def impl (x : Expr [Any ])(implicit reflect : Reflection ): Expr [Unit ] = {
14+ import reflect ._
15+ val pos = x.unseal.underlyingArgument.pos
16+ val code = x.unseal.underlyingArgument.showCode
17+ ' {
18+ println($ {posStr(reflect)(pos)})
19+ println($ {code.toExpr})
20+ }
21+ }
22+
23+ def impl2 [T ](x : quoted.Type [T ])(implicit reflect : Reflection ): Expr [Unit ] = {
24+ import reflect ._
25+ val pos = x.unseal.pos
26+ val code = x.unseal.showCode
27+ ' {
28+ println($ {posStr(reflect)(pos)})
29+ println($ {code.toExpr})
30+ }
31+ }
32+
33+ def posStr (relfection : Reflection )(pos : relfection.Position ): Expr [String ] = {
34+ import relfection ._
35+ s " ${pos.sourceFile.getFileName.toString}:[ ${pos.start}.. ${pos.end}] " .toExpr
36+ }
37+ }
Original file line number Diff line number Diff line change 1+
2+ import Macros ._
3+
4+ object Test {
5+ def main (args : Array [String ]): Unit = {
6+ val a : String = " abc"
7+ val b : 42 = 42
8+ def c : String = " abc"
9+ def d : 42 = 42
10+
11+ fun(a) // ERROR
12+ fun(b) // ERROR
13+ fun(c)
14+ fun(d)
15+ fun(" abc" ) // ERROR
16+ fun(" abc" : String )
17+ fun(s " abc ${" def" }" )
18+
19+ fun2(a) // ERROR
20+ fun2(b) // ERROR
21+ fun2(c)
22+ fun2(d)
23+ fun2(" abc" ) // ERROR
24+ fun2(" abc" : String )
25+ fun2(s " abc ${" def" }" )
26+
27+ type T
28+ type U = " abc"
29+
30+ fun3[T ] // ERROR
31+ fun3[String ] // ERROR
32+ fun3[" abc" ] // ERROR
33+ fun3[U ] // ERROR
34+ }
35+ // FIXME all the lines marked as ERROR have the wrong position on the three of the argument.
36+ // they all have as source file this file but the span of `'x` in `fun` or `fun2`.
37+ // see #6026 and #6027
38+ }
You can’t perform that action at this time.
0 commit comments