File tree 3 files changed +20
-2
lines changed 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,12 @@ object Impls{
128
128
def text [T : c.WeakTypeTag ](c : Compat .Context )(v : c.Expr [T ]): c.Expr [sourcecode.Text [T ]] = {
129
129
import c .universe ._
130
130
val fileContent = new String (v.tree.pos.source.content)
131
- val start = v.tree.collect{case tree => tree.pos.startOrPoint}.min
131
+ val start = v.tree.collect {
132
+ case treeVal => treeVal.pos match {
133
+ case NoPosition ⇒ Int .MaxValue
134
+ case p ⇒ p.startOrPoint
135
+ }
136
+ }.min
132
137
val g = c.asInstanceOf [reflect.macros.runtime.Context ].global
133
138
val parser = g.newUnitParser(fileContent.drop(start))
134
139
parser.expr()
@@ -185,4 +190,4 @@ object Impls{
185
190
}.mkString.dropRight(1 )
186
191
c.Expr [T ](q """ ${c.prefix}( $renderedPath) """ )
187
192
}
188
- }
193
+ }
Original file line number Diff line number Diff line change
1
+ package sourcecode
2
+
3
+ object Regressions {
4
+ def bug17 () = {
5
+ val text = sourcecode.Text (Seq (1 ).map(_+1 ))
6
+ assert(text.source == " Seq(1).map(_+1)" )
7
+ }
8
+ def main () = {
9
+ bug17()
10
+ }
11
+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ object Tests{
30
30
DebugName .main()
31
31
println(" ================Debug Lite================" )
32
32
DebugLite .main()
33
+ println(" ================Regressions===============" )
34
+ Regressions .main()
33
35
println(" ================Test Ended================" )
34
36
}
35
37
}
You can’t perform that action at this time.
0 commit comments