Don't warn on by-name keys

.. which is apparently what the type of bare vals in *.sbt files are.

Fixes #3299, again.
This commit is contained in:
Dale Wijnand 2017-09-11 14:46:23 +01:00
parent 8d9a3a35d2
commit d3d105515a
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
2 changed files with 23 additions and 1 deletions

View File

@ -65,7 +65,7 @@ abstract class BaseTaskLinterDSL extends LinterDSL {
val wrapperName = nme.decodedName.toString
val (qualName, isSettingKey) =
Option(qual.symbol)
.map(sym => (sym.name.decodedName.toString, sym.info <:< typeOf[SettingKey[_]]))
.map(sym => (sym.name.decodedName.toString, qual.tpe <:< typeOf[SettingKey[_]]))
.getOrElse((ap.pos.lineContent, false))
if (!isSettingKey && !shouldIgnore && isTask(wrapperName, tpe.tpe, qual)) {

View File

@ -151,6 +151,15 @@ class TaskPosSpec {
}
}
locally {
import sbt._, Def._
def withKey(foo: => SettingKey[String]) = {
Def.task { if (true) foo.value }
}
val foo = settingKey[String]("")
withKey(foo)
}
locally {
import sbt._
import sbt.Def._
@ -171,4 +180,17 @@ class TaskPosSpec {
(1 to 10).map(_ => foo.value)
}
}
locally {
import sbt._, Def._
def withKey(bar: => SettingKey[Int]) = {
Def.task {
List(42).map { _ =>
if (true) bar.value
}
}
}
val bar = settingKey[Int]("bar")
withKey(bar)
}
}