diff --git a/main/settings/src/main/scala/sbt/Append.scala b/main/settings/src/main/scala/sbt/Append.scala index 2bf3ba64e..ee7738b24 100644 --- a/main/settings/src/main/scala/sbt/Append.scala +++ b/main/settings/src/main/scala/sbt/Append.scala @@ -23,6 +23,14 @@ object Append { def appendValues(a: Seq[T], b: Seq[V]): Seq[T] = a ++ (b map { x => (x: T) }) def appendValue(a: Seq[T], b: V): Seq[T] = a :+ (b: T) } + implicit def appendList[T, V <: T]: Sequence[List[T], List[V], V] = new Sequence[List[T], List[V], V] { + def appendValues(a: List[T], b: List[V]): List[T] = a ::: b + def appendValue(a: List[T], b: V): List[T] = a :+ b + } + implicit def appendListImplicit[T, V <% T]: Sequence[List[T], List[V], V] = new Sequence[List[T], List[V], V] { + def appendValues(a: List[T], b: List[V]): List[T] = a ::: (b map { x => (x: T) }) + def appendValue(a: List[T], b: V): List[T] = a :+ (b: T) + } implicit def appendString: Value[String, String] = new Value[String, String] { def appendValue(a: String, b: String) = a + b } @@ -47,4 +55,4 @@ object Append { def appendValues(a: Map[A, B], b: Map[X, Y]): Map[A, B] = a ++ b def appendValue(a: Map[A, B], b: (X, Y)): Map[A, B] = a + b } -} \ No newline at end of file +} diff --git a/main/settings/src/test/scala/UsageTest.scala b/main/settings/src/test/scala/UsageTest.scala index 24c75fe3b..b6c3a9ca9 100644 --- a/main/settings/src/test/scala/UsageTest.scala +++ b/main/settings/src/test/scala/UsageTest.scala @@ -13,7 +13,7 @@ import complete.{ DefaultParsers, Parsers } val x = task { set.value } val y = task { true } val z = task { if(y.value) x.value else plain.value } - val a = taskDyn { + val a = taskDyn { if(y.value) z else x } }*/ @@ -38,6 +38,8 @@ object Assign { val dummy3 = settingKey[complete.Parser[(String, Int)]]("dummy3") val tsk: complete.Parser[Task[String]] = ??? val itsk: Initialize[InputTask[Int]] = ??? + val seqSetting = settingKey[Seq[String]]("seqSetting") + val listSetting = settingKey[List[String]]("listSetting") /* def azy = sk.value @@ -100,4 +102,14 @@ object Assign { def forallIn[T](key: Initialize[T]): Initialize[Seq[T]] = Def.setting { key.value :: Nil } -} \ No newline at end of file + + // Test that Append.Sequence instances for Seq/List work and don't mess up with each other + seqSetting := Seq("test1") + seqSetting ++= Seq("test2") + seqSetting ++= List("test3") + seqSetting += "test4" + + listSetting := List("test1") + listSetting ++= List("test2") + listSetting += "test4" +} diff --git a/notes/0.13.10/add-append.sequence-list.markdown b/notes/0.13.10/add-append.sequence-list.markdown new file mode 100644 index 000000000..0f9ad05ad --- /dev/null +++ b/notes/0.13.10/add-append.sequence-list.markdown @@ -0,0 +1,11 @@ +[@pdalpra]: http://github.com/pdalpra +[2107]: https://github.com/sbt/sbt/issues/2107 +[2114]: https://github.com/sbt/sbt/pull/2114 + +### Fixes with compatibility implications + +### Improvements + +### Bug fixes + +- Add an Append.Sequence instance for List, allow +=/++= on `developers` SettingKey [#2107][2107]/[#2114][2114] by [@pdalpra][@pdalpra]