set position on parameter references in task/setting macros

This commit is contained in:
Mark Harrah 2013-06-19 11:53:11 -04:00
parent 2f9d68e869
commit 284cddff70
3 changed files with 4 additions and 3 deletions

View File

@ -308,7 +308,7 @@ object TaskMacro
qual.foreach(checkQual) qual.foreach(checkQual)
val vd = util.freshValDef(tpe, qual.symbol) // val $x: <tpe> val vd = util.freshValDef(tpe, qual.symbol) // val $x: <tpe>
result = Some( (qual, tpe, vd) ) result = Some( (qual, tpe, vd) )
val tree = util.refVal(vd) // $x val tree = util.refVal(vd, qual.pos) // $x
tree.setPos(qual.pos) // position needs to be set so that wrapKey passes the position onto the wrapper tree.setPos(qual.pos) // position needs to be set so that wrapKey passes the position onto the wrapper
assert(tree.tpe != null, "Null type: " + tree) assert(tree.tpe != null, "Null type: " + tree)
tree.setType(tpe) tree.setType(tpe)

View File

@ -144,11 +144,12 @@ final class ContextUtil[C <: Context](val ctx: C)
} }
/** Create a Tree that references the `val` represented by `vd`. */ /** Create a Tree that references the `val` represented by `vd`. */
def refVal(vd: ValDef): Tree = def refVal(vd: ValDef, pos: Position): Tree =
{ {
val t = Ident(vd.name) val t = Ident(vd.name)
assert(vd.tpt.tpe != null, "val type is null: " + vd + ", tpt: " + vd.tpt.tpe) assert(vd.tpt.tpe != null, "val type is null: " + vd + ", tpt: " + vd.tpt.tpe)
t.setType(vd.tpt.tpe) t.setType(vd.tpt.tpe)
t.setPos(pos)
t t
} }

View File

@ -162,7 +162,7 @@ object Instance
qual.foreach(checkQual) qual.foreach(checkQual)
val vd = util.freshValDef(tpe, qual.symbol) val vd = util.freshValDef(tpe, qual.symbol)
inputs ::= new Input(tpe, qual, vd) inputs ::= new Input(tpe, qual, vd)
util.refVal(vd) util.refVal(vd, qual.pos)
} }
def sub(name: String, tpe: Type, qual: Tree): Converted[c.type] = def sub(name: String, tpe: Type, qual: Tree): Converted[c.type] =
{ {