File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,12 @@ object Impls{
128128 def text [T : c.WeakTypeTag ](c : Compat .Context )(v : c.Expr [T ]): c.Expr [sourcecode.Text [T ]] = {
129129 import c .universe ._
130130 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
132137 val g = c.asInstanceOf [reflect.macros.runtime.Context ].global
133138 val parser = g.newUnitParser(fileContent.drop(start))
134139 parser.expr()
@@ -185,4 +190,4 @@ object Impls{
185190 }.mkString.dropRight(1 )
186191 c.Expr [T ](q """ ${c.prefix}( $renderedPath) """ )
187192 }
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{
3030 DebugName .main()
3131 println(" ================Debug Lite================" )
3232 DebugLite .main()
33+ println(" ================Regressions===============" )
34+ Regressions .main()
3335 println(" ================Test Ended================" )
3436 }
3537}
You can’t perform that action at this time.
0 commit comments