Fix task macro's handling of Symbol owners in <qual>.value

The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes #1150
This commit is contained in:
Jason Zaugg 2014-03-07 17:48:31 +01:00
parent 84b79f9bc1
commit ef826584c2
1 changed files with 13 additions and 10 deletions

View File

@ -226,17 +226,20 @@ final class ContextUtil[C <: Context](val ctx: C)
object appTransformer extends Transformer
{
override def transform(tree: Tree): Tree =
tree match
{
case ApplyTree(TypeApply(Select(_, nme), targ :: Nil), qual :: Nil) => subWrapper(nme.decoded, targ.tpe, qual, tree) match {
case Converted.Success(t, finalTx) => finalTx(t)
case Converted.Failure(p,m) => ctx.abort(p, m)
case _: Converted.NotApplicable[_] => super.transform(tree)
}
tree match {
case ApplyTree(TypeApply(Select(_, nme), targ :: Nil), qual :: Nil) =>
subWrapper(nme.decoded, targ.tpe, qual, tree) match {
case Converted.Success(t, finalTx) =>
changeOwner(qual, currentOwner, initialOwner) // Fixes https://github.com/sbt/sbt/issues/1150
finalTx(t)
case Converted.Failure(p,m) => ctx.abort(p, m)
case _: Converted.NotApplicable[_] => super.transform(tree)
}
case _ => super.transform(tree)
}
}
appTransformer.transform(t)
appTransformer.atOwner(initialOwner) {
appTransformer.transform(t)
}
}
}
}