summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-18 04:55:02 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-18 04:55:02 -0700
commitff954063ae75376d284bb09302ea3ccba8cdc268 (patch)
treeb3a1e0582bbef0da15c3e3241afdbbb9cb794ef0 /src/compiler
parent2b6682e28db5ff7d2fe43f1ea94578f28c300ecf (diff)
parent72de4d83490190cec97fa56cfc5c18af6bb355d1 (diff)
downloadscala-ff954063ae75376d284bb09302ea3ccba8cdc268.tar.gz
scala-ff954063ae75376d284bb09302ea3ccba8cdc268.tar.bz2
scala-ff954063ae75376d284bb09302ea3ccba8cdc268.zip
Merge pull request #928 from hubertp/2.10.x-issue/6076
Fixed SI-6076. Range positions for macro-based string interpolation.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/reflect/FastTrack.scala2
-rw-r--r--src/compiler/scala/tools/reflect/MacroImplementations.scala9
2 files changed, 5 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala
index 8ea66979bc..63ecfa32b2 100644
--- a/src/compiler/scala/tools/reflect/FastTrack.scala
+++ b/src/compiler/scala/tools/reflect/FastTrack.scala
@@ -43,7 +43,7 @@ trait FastTrack {
ApiUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) }
MacroContextReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExprForMacroContext(c.prefix.tree, expr) }
ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree }
- StringContext_f bindTo { case (c, Apply(Select(Apply(_, parts), _), args)) => c.macro_StringInterpolation_f(parts, args) }
+ StringContext_f bindTo { case (c, app@Apply(Select(Apply(_, parts), _), args)) => c.macro_StringInterpolation_f(parts, args, app.pos) }
registry
}
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala
index a5f7928f55..604bd7cd1a 100644
--- a/src/compiler/scala/tools/reflect/MacroImplementations.scala
+++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala
@@ -8,9 +8,9 @@ import scala.collection.mutable.Stack
abstract class MacroImplementations {
val c: Context
- import c.universe._
+ import c.universe.{Position => SPosition, _}
- def macro_StringInterpolation_f(parts: List[Tree], args: List[Tree]): Tree = {
+ def macro_StringInterpolation_f(parts: List[Tree], args: List[Tree], origApplyPos: SPosition): Tree = {
// the parts all have the same position information (as the expression is generated by the compiler)
// the args have correct position information
@@ -25,7 +25,6 @@ abstract class MacroImplementations {
c.abort(args(parts.length-1).pos,
"too many arguments for interpolated string")
}
-
val stringParts = parts map {
case Literal(Constant(s: String)) => s;
case _ => throw new IllegalArgumentException("argument parts must be a list of string literals")
@@ -39,7 +38,7 @@ abstract class MacroImplementations {
def defval(value: Tree, tpe: Type): Unit = {
val freshName = newTermName(c.fresh("arg$"))
- evals += ValDef(Modifiers(), freshName, TypeTree(tpe), value)
+ evals += ValDef(Modifiers(), freshName, TypeTree(tpe) setPos value.pos.focus, value) setPos value.pos
ids += Ident(freshName)
}
@@ -141,7 +140,7 @@ abstract class MacroImplementations {
List(ids: _* )
);
- Block(evals.toList, expr)
+ Block(evals.toList, atPos(origApplyPos.focus)(expr)) setPos origApplyPos.makeTransparent
}
} \ No newline at end of file