Skip to content

Commit

Permalink
Fix NPE in task macro accessing q"{...}".symbol.pos
Browse files Browse the repository at this point in the history
We shouldn't assume that the qualifier of a `Select` is a
`SymTree`; it may be a `Block`. One place that happens
is after the transformation of named/defaults applications.
That causes the reported `NullPointerException'.

In any case, using `qual.symbol.pos` sense here; it yields the
position of the defintions *referred to* by `qual`, not the
position of `qual` itself.

Both problems are easily fixed: use `qual.pos` instead.

Fixes #1107
  • Loading branch information
retronym authored and eed3si9n committed Mar 21, 2014
1 parent 01abb7d commit 3e9a7c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions sbt/src/sbt-test/project/setting-macro/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ key1 := {
)
()
}

// https://github.com/sbt/sbt/issues/1107
def appcfgTask(a: String, b: String) = Def.task("")

TaskKey[Unit]("test") := appcfgTask(b = "", a = "").value
2 changes: 1 addition & 1 deletion util/appmacro/src/main/scala/sbt/appmacro/Instance.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ object Instance
def addType(tpe: Type, qual: Tree, selection: Tree): Tree =
{
qual.foreach(checkQual)
val vd = util.freshValDef(tpe, qual.symbol.pos, functionSym)
val vd = util.freshValDef(tpe, qual.pos, functionSym)
inputs ::= new Input(tpe, qual, vd)
util.refVal(selection, vd)
}
Expand Down

0 comments on commit 3e9a7c7

Please sign in to comment.