From 53bbb996171e22475efb33604ffe25c4c6769462 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Oct 2017 02:43:50 -0400 Subject: [PATCH] Fixes Zero / Zero / Zero / name handling Prior to this change `Zero / Zero / Zero / name` broke as folllows: ``` scala> Zero / Zero / Zero / name Zero / Zero / Zero / name :18: error: inferred type arguments [sbt.Zero.type] do not conform to method /'s type parameter bounds [K <: sbt.SlashSyntax.Key[K]] Zero / Zero / Zero / name ^ ``` --- main/src/main/scala/sbt/SlashSyntax.scala | 8 +++++++- sbt/src/sbt-test/project/unified/build.sbt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/SlashSyntax.scala b/main/src/main/scala/sbt/SlashSyntax.scala index 14d6d476c..634a86b75 100644 --- a/main/src/main/scala/sbt/SlashSyntax.scala +++ b/main/src/main/scala/sbt/SlashSyntax.scala @@ -1,6 +1,7 @@ package sbt import sbt.librarymanagement.Configuration +import sbt.internal.util.AttributeKey /** * SlashSyntax implements the slash syntax to scope keys for build.sbt DSL. @@ -57,7 +58,12 @@ object SlashSyntax { } /** RichConfiguration wraps a configuration to provide the `/` operator for scoping. */ - final class RichConfiguration(protected val scope: Scope) extends RichScopeLike + final class RichConfiguration(protected val scope: Scope) extends RichScopeLike { + + // This is for handling `Zero / Zero / Zero / name`. + def /(taskAxis: ScopeAxis[AttributeKey[_]]): RichScope = + new RichScope(scope.copy(task = taskAxis)) + } /** Both `Scoped.ScopingSetting` and `Scoped` are parents of `SettingKey`, `TaskKey` and * `InputKey`. We'll need both, so this is a convenient type alias. */ diff --git a/sbt/src/sbt-test/project/unified/build.sbt b/sbt/src/sbt-test/project/unified/build.sbt index 935e32855..7f9835fea 100644 --- a/sbt/src/sbt-test/project/unified/build.sbt +++ b/sbt/src/sbt-test/project/unified/build.sbt @@ -10,6 +10,7 @@ lazy val root = (project in file(".")) Compile / console / scalacOptions += "-Ywarn-numeric-widen", projA / Compile / console / scalacOptions += "-feature", Zero / Zero / name := "foo", + Zero / Zero / Zero / name := "foo", libraryDependencies += uTest % Test, testFrameworks += new TestFramework("utest.runner.Framework"),