Merge pull request #3513 from dwijnand/allow-late-settingkey-evals

Don't warn on by-name keys
This commit is contained in:
eugene yokota 2017-09-12 14:22:58 -04:00 committed by GitHub
commit cedb902d17
3 changed files with 26 additions and 4 deletions

View File

@ -9,7 +9,7 @@ def buildLevelSettings: Seq[Setting[_]] =
inThisBuild(
Seq(
organization := "org.scala-sbt",
version := "1.0.1-SNAPSHOT",
version := "1.0.2-SNAPSHOT",
description := "sbt is an interactive build tool",
bintrayOrganization := Some("sbt"),
bintrayRepository := {

View File

@ -2,7 +2,7 @@ package sbt.std
import sbt.SettingKey
import sbt.internal.util.ConsoleAppender
import sbt.internal.util.appmacro.{ Convert, Converted, LinterDSL }
import sbt.internal.util.appmacro.{ Convert, LinterDSL }
import scala.collection.mutable.{ HashSet => MutableSet }
import scala.io.AnsiColor
@ -27,7 +27,7 @@ abstract class BaseTaskLinterDSL extends LinterDSL {
def handleUncheckedAnnotation(exprAtUseSite: Tree, tt: TypeTree): Unit = {
tt.original match {
case Annotated(annot, arg) =>
case Annotated(annot, _) =>
Option(annot.tpe) match {
case Some(AnnotatedType(annotations, _)) =>
val tpeAnnotations = annotations.flatMap(ann => Option(ann.tree.tpe).toList)
@ -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)
}
}