Skip to content

Commit

Permalink
Migrate most of the internal usage of in
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Feb 22, 2021
1 parent 833024b commit 695261a
Show file tree
Hide file tree
Showing 41 changed files with 350 additions and 279 deletions.
2 changes: 1 addition & 1 deletion main-settings/src/main/scala/sbt/SlashSyntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object SlashSyntax {
}

/** RichScope wraps a general scope to provide the `/` operator for scoping. */
final class RichScope(protected val scope: Scope) extends HasSlashKey
final class RichScope(protected val scope: Scope) extends HasSlashKeyOrAttrKey

}

Expand Down
2 changes: 2 additions & 0 deletions main-settings/src/test/scala/sbt/BuildSettingsInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import sbt.ConfigKey
import sbt.librarymanagement.syntax._
import sbt.{ InputKey, SettingKey, TaskKey }
import sbt.internal.util.{ AttributeKey, AttributeMap }
import scala.annotation.nowarn

object BuildSettingsInstances {
val genFile: Gen[File] = Gen.oneOf(new File("."), new File("/tmp")) // for now..
Expand Down Expand Up @@ -99,6 +100,7 @@ object BuildSettingsInstances {
def genSettingKey[A: Manifest]: Gen[SettingKey[A]] = genLabel map (x => SettingKey[A](x.value))
def genTaskKey[A: Manifest]: Gen[TaskKey[A]] = genLabel map (x => TaskKey[A](x.value))

@nowarn
def withScope[K <: Scoped.ScopingSetting[K]](keyGen: Gen[K]): Arbitrary[K] = Arbitrary {
Gen.frequency(
5 -> keyGen,
Expand Down
3 changes: 3 additions & 0 deletions main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ package sbt
import org.scalatest.FlatSpec
import sbt.internal.util.{ AttributeKey, AttributeMap }
import sbt.io.syntax.file
import scala.annotation.nowarn

class ScopeDisplaySpec extends FlatSpec {
val project = ProjectRef(file("foo/bar"), "bar")
val mangledName = "bar_slash_blah_blah_blah"

@nowarn
val scopedKey = Def.ScopedKey(Scope.Global in project, AttributeKey[Task[String]](mangledName))
val am = AttributeMap.empty.put(Scope.customShowString, "blah")
val sanitizedKey = scopedKey.copy(scope = scopedKey.scope.copy(extra = Select(am)))
Expand Down
2 changes: 2 additions & 0 deletions main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import sbt.ConfigKey
import sbt.internal.util.AttributeKey

import BuildSettingsInstances._
import scala.annotation.nowarn

@nowarn
object SlashSyntaxSpec extends Properties("SlashSyntax") with SlashSyntax {
property("Global / key == key in Global") = {
forAll((k: Key) => expectValue(k in Global)(Global / k))
Expand Down
19 changes: 10 additions & 9 deletions main/src/main/scala/sbt/Cross.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import java.io.File

import sbt.Def.{ ScopedKey, Setting }
import sbt.Keys._
import sbt.SlashSyntax0._
import sbt.internal.Act
import sbt.internal.CommandStrings._
import sbt.internal.inc.ScalaInstance
Expand Down Expand Up @@ -102,9 +103,9 @@ object Cross {

private def crossVersions(extracted: Extracted, proj: ResolvedReference): Seq[String] = {
import extracted._
(crossScalaVersions in proj get structure.data) getOrElse {
((proj / crossScalaVersions) get structure.data) getOrElse {
// reading scalaVersion is a one-time deal
(scalaVersion in proj get structure.data).toSeq
((proj / scalaVersion) get structure.data).toSeq
}
}

Expand Down Expand Up @@ -358,16 +359,16 @@ object Cross {
instance match {
case Some((home, inst)) =>
Seq(
scalaVersion in scope := version,
crossScalaVersions in scope := scalaVersions,
scalaHome in scope := Some(home),
scalaInstance in scope := inst
scope / scalaVersion := version,
scope / crossScalaVersions := scalaVersions,
scope / scalaHome := Some(home),
scope / scalaInstance := inst
)
case None =>
Seq(
scalaVersion in scope := version,
crossScalaVersions in scope := scalaVersions,
scalaHome in scope := None
scope / scalaVersion := version,
scope / crossScalaVersions := scalaVersions,
scope / scalaHome := None
)
}
}
Expand Down

0 comments on commit 695261a

Please sign in to comment.