Communicate narrowing by adding case

This commit is contained in:
Eugene Yokota 2023-11-25 20:49:04 -05:00
parent a7d5694c67
commit bde26f6c51
3 changed files with 17 additions and 26 deletions

View File

@ -27,7 +27,8 @@ private[sbt] final class Previous(streams: Streams, referenced: IMap[Previous.Ke
// We can't use mapValues to transform the map because mapValues is lazy and evaluates the
// transformation function every time a value is fetched from the map, defeating the entire
// purpose of ReferencedValue.
for (referenced.TPair(k, v) <- referenced.toTypedSeq) map = map.put(k, new ReferencedValue(v))
for case referenced.TPair(k, v) <- referenced.toTypedSeq do
map = map.put(k, new ReferencedValue(v))
private[this] final class ReferencedValue[T](referenced: Referenced[T]) {
lazy val previousValue: Option[T] = referenced.read(streams)
@ -122,10 +123,10 @@ object Previous {
// We first collect all of the successful tasks and write their scoped key into a map
// along with their values.
val successfulTaskResults = (for {
results.TPair(task, Result.Value(v)) <- results.toTypedSeq
val successfulTaskResults = (for
case results.TPair(task, Result.Value(v)) <- results.toTypedSeq
key <- task.info.attributes.get(Def.taskDefinitionKey).asInstanceOf[Option[AnyTaskKey]]
} yield key -> v).toMap
yield key -> v).toMap
// We then traverse the successful results and look up all of the referenced values for
// each of these tasks. This can be a many to one relationship if multiple tasks refer
// the previous value of another task. For each reference we find, we check if the task has

View File

@ -396,9 +396,8 @@ object EvaluateTask {
}
import ExceptionCategory._
for {
(key, msg, Some(ex)) <- keyed
} do
for case (key, msg, Some(ex)) <- keyed
do
def log = getStreams(key, streams).log
ExceptionCategory(ex) match {
case AlreadyHandled => ()

View File

@ -335,19 +335,16 @@ private[sbt] object ClasspathImpl {
conf: Configuration,
data: Settings[Scope],
deps: BuildDependencies
): Seq[(ProjectRef, String)] = {
): Seq[(ProjectRef, String)] =
val visited = (new LinkedHashSet[(ProjectRef, String)]).asScala
def visit(p: ProjectRef, c: Configuration): Unit = {
def visit(p: ProjectRef, c: Configuration): Unit =
val applicableConfigs = allConfigs(c)
for {
ac <- applicableConfigs
} // add all configurations in this project
for ac <- applicableConfigs do
// add all configurations in this project
visited add (p -> ac.name)
val masterConfs = names(getConfigurations(projectRef, data).toVector)
for {
ClasspathDep.ResolvedClasspathDependency(dep, confMapping) <- deps.classpath(p)
} {
for case ClasspathDep.ResolvedClasspathDependency(dep, confMapping) <- deps.classpath(p) do
val configurations = getConfigurations(dep, data)
val mapping =
mapped(
@ -358,21 +355,15 @@ private[sbt] object ClasspathImpl {
"*->compile"
)
// map master configuration 'c' and all extended configurations to the appropriate dependency configuration
for {
for
ac <- applicableConfigs
depConfName <- mapping(ac.name)
} {
for {
depConf <- confOpt(configurations, depConfName)
} if (!visited((dep, depConfName))) {
visit(dep, depConf)
}
}
}
}
do
for depConf <- confOpt(configurations, depConfName) do
if !visited((dep, depConfName)) then visit(dep, depConf)
visit(projectRef, conf)
visited.toSeq
}
end interSort
def mapped(
confString: Option[String],