Merge pull request #9235 from eed3si9n/bport2/bump-scala

[2.0.x] Scala 3.8.3
This commit is contained in:
eugene yokota 2026-05-17 01:13:21 -04:00 committed by GitHub
commit 26c7cd825e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
59 changed files with 91 additions and 87 deletions

View File

@ -992,7 +992,7 @@ lazy val sbtwProj = (project in file("sbtw"))
commonSettings,
name := "sbtw",
description := "Windows drop-in launcher for sbt (replaces sbt.bat)",
scalaVersion := "3.8.2",
scalaVersion := "3.8.3",
crossPaths := false,
Compile / mainClass := Some("sbtw.Main"),
libraryDependencies += "com.github.scopt" %% "scopt" % "4.1.0",

View File

@ -258,7 +258,7 @@ private[sbt] case class SbtParser(
|$code
|}""".stripMargin
val fileName = path.id
val reporterId = s"$fileName-${Random.nextInt}"
val reporterId = s"$fileName-${Random.nextInt()}"
val sourceFile = SourceFile(
VirtualFile(reporterId, wrapCode.getBytes(StandardCharsets.UTF_8)),
scala.io.Codec.UTF8

View File

@ -29,7 +29,7 @@ object SbtParserErrorSpec extends AbstractSpec {
print(s"Processing ${file.getFileName}: ")
val vf = converter.toVirtualFile(file)
val buildSbt = Source.fromFile(file.toUri).getLines.toSeq
val buildSbt = Source.fromFile(file.toUri).getLines().toSeq
val message = interceptMessageException(SbtParser(vf, buildSbt))
println(message)
assert(message.contains(file.getFileName.toString))

View File

@ -28,7 +28,7 @@ Create an initial build in `something`. Like a real build using sbt. I'm sure yo
```scala
name := "foo"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
```
I also have `Hello.scala`:
@ -107,7 +107,7 @@ import scala.sys.process.Process
lazy val check = taskKey[Unit]("check")
name := "foo"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
check := {
val pkg = (Compile / packageBin).value
val conv = fileConverter.value

View File

@ -22,7 +22,7 @@ $ sbt --server
### Clearing out boot and local cache
sbt consists of lots of JAR files. When running sbt locally, these JAR artifacts are cached in the `boot` directory under `$HOME/.sbt/boot/scala-3.8.2/org.scala-sbt/sbt/2.0.0-RC9-bin-SNAPSHOT` directory (The Scala version and sbt version part changes).
sbt consists of lots of JAR files. When running sbt locally, these JAR artifacts are cached in the `boot` directory under `$HOME/.sbt/boot/scala-3.8.3/org.scala-sbt/sbt/2.0.0-RC9-bin-SNAPSHOT` directory (The Scala version and sbt version part changes).
In order to see a change you've made to sbt's source code, this cache MUST be cleared. To clear this out, from the sbt shell in your application run:

View File

@ -3,7 +3,7 @@ lazy val check2 = taskKey[Unit]("")
lazy val root = (project in file("."))
.settings(
scalaVersion := "3.8.2",
scalaVersion := "3.8.3",
name := "Hello",
libraryDependencies += "com.eed3si9n.verify" %% "verify" % "1.0.0" % Test,
testFrameworks += new TestFramework("verify.runner.Framework"),

View File

@ -1,5 +1,5 @@
lazy val root = (project in file("."))
.settings(
scalaVersion := "3.8.2",
scalaVersion := "3.8.3",
name := "Hello",
)

View File

@ -172,9 +172,9 @@ trait ShellScriptUtil extends BasicTestSuite {
BasicIO.processFully(processLine)
)
)
if p.exitValue != 0 then
if p.exitValue() != 0 then
lines.foreach(l => Console.err.println(l))
sys.error(s"process exit with ${p.exitValue}")
sys.error(s"process exit with ${p.exitValue()}")
f(lines.toList)
()
finally

View File

@ -38,7 +38,7 @@ class LockFileSpec extends AnyFunSuite {
),
metadata = LockFileMetadata(
sbtVersion = "2.0.0",
scalaVersion = Some("3.8.2")
scalaVersion = Some("3.8.3")
)
)
@ -59,7 +59,7 @@ class LockFileSpec extends AnyFunSuite {
assert(readData.configurations.head.dependencies.head.organization == "org.scala-lang")
assert(readData.configurations.head.dependencies.head.version == "2.13.16")
assert(readData.metadata.sbtVersion == "2.0.0")
assert(readData.metadata.scalaVersion == Some("3.8.2"))
assert(readData.metadata.scalaVersion == Some("3.8.3"))
}
}
@ -111,7 +111,7 @@ class LockFileSpec extends AnyFunSuite {
configurations = Vector.empty,
metadata = LockFileMetadata(
sbtVersion = "2.0.0",
scalaVersion = Some("3.8.2")
scalaVersion = Some("3.8.3")
)
)

View File

@ -197,7 +197,7 @@ private class React(
case NonFatal(_) => ()
override def notifyExit(p: Process): Unit =
if !process.isAlive && !promise.isCompleted then
if !process.isAlive() && !promise.isCompleted then
val exitCode = process.exitValue()
if exitCode != 0 then
promise.failure(new RuntimeException(s"Forked test process exited with code $exitCode"))

View File

@ -110,7 +110,7 @@ class WorkerProxy(
input.close()
serverSocket.foreach(_.close())
def blockForExitCode(): Int =
if !process.isAlive then process.exitValue()
if !process.isAlive() then process.exitValue()
else Fork.blockForExitCode(process)
/** print a line into stdin of the worker process. */

View File

@ -102,7 +102,7 @@ private[sbt] object PluginCross {
case VersionNumber(Seq(0, 12, _*), _, _) => "2.9.2"
case VersionNumber(Seq(0, 13, _*), _, _) => "2.10.7"
case VersionNumber(Seq(1, 0, _*), _, _) => "2.12.21"
case VersionNumber(Seq(2, _*), _, _) => "3.8.2"
case VersionNumber(Seq(2, _*), _, _) => "3.8.3"
case _ => sys.error(s"Unsupported sbt binary version: $sv")
}
}

View File

@ -68,7 +68,7 @@ private[sbt] abstract class AbstractTaskExecuteProgress(
timings.forEach { (task, timing) =>
if (timing.isActive) result += task -> (now - timing.startNanos).nanos
}
result.result
result.result()
}
override def afterRegistered(

View File

@ -100,7 +100,7 @@ private[sbt] final class CommandExchange {
Option(deadline match {
case Some(d: Deadline) =>
commandQueue.poll(d.timeLeft.toMillis + 1, TimeUnit.MILLISECONDS) match {
case null if idleDeadline.fold(false)(_.isOverdue) =>
case null if idleDeadline.fold(false)(_.isOverdue()) =>
state.foreach { s =>
s.get(BasicKeys.serverIdleTimeout) match {
case Some(Some(d)) => s.log.info(s"sbt idle timeout of $d expired")

View File

@ -501,7 +501,7 @@ private[sbt] object Continuous {
* increase in latency.
*/
@tailrec def aggregate(res: Seq[Event]): Seq[Event] =
if (limit.isOverdue) res
if (limit.isOverdue()) res
else {
monitor.poll(antiEntropyPollPeriod) match {
case s if s.nonEmpty => aggregate(res ++ s)

View File

@ -194,7 +194,7 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe
override final def close(): Unit = shutdown()
override def shutdown(): Unit = {
val deadline = 10.seconds.fromNow
while (jobSet.nonEmpty && !deadline.isOverdue) {
while (jobSet.nonEmpty && !deadline.isOverdue()) {
jobSet.headOption.foreach { case handle: ThreadJobHandle @unchecked =>
if (handle.job.isRunning()) {
handle.job.shutdown()

View File

@ -86,7 +86,7 @@ private[sbt] class TaskProgress(
private def doReport(): Unit = {
val runnable: Runnable = () => {
if (nextReport.get.isOverdue) {
if (nextReport.get.isOverdue()) {
report()
}
}

View File

@ -219,7 +219,7 @@ private[sbt] object Definition {
}
private[sbt] def getAnalyses: Future[Seq[Analysis]] = {
val result = Promise[Seq[Analysis]]
val result = Promise[Seq[Analysis]]()
new Thread("sbt-get-analysis-thread") {
setDaemon(true)

View File

@ -765,7 +765,7 @@ final class NetworkChannel(
private def empty = TerminalPropertiesResponse(0, 0, false, false, false, false)
def getProperties(block: Boolean): Unit = {
if (alive.get) {
if (!pending.get && Option(lastUpdate.get).fold(true)(d => (d + 1.second).isOverdue)) {
if (!pending.get && Option(lastUpdate.get).fold(true)(d => (d + 1.second).isOverdue())) {
pending.set(true)
val queue = VirtualTerminal.sendTerminalPropertiesQuery(term.name, jsonRpcRequest)
val update: Runnable = () => {

View File

@ -245,7 +245,7 @@ private[sbt] object Settings {
val created = createdBuilder.result()
val modified = modifiedBuilder.result()
if (created.isEmpty && deleted.isEmpty && modified.isEmpty) {
FileChanges.unmodified(unmodifiedBuilder.result)
FileChanges.unmodified(unmodifiedBuilder.result())
} else {
FileChanges(created, deleted, modified, unmodified)
}

View File

@ -4,7 +4,7 @@ import Keys.*
object Dependencies {
// WARNING: Please Scala update versions in PluginCross.scala too
val scala213 = "2.13.16"
val scala3 = "3.8.2"
val scala3 = "3.8.3"
val scala212 = "2.12.21"
val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up")
val baseScalaVersion = scala3

View File

@ -5,7 +5,7 @@ lazy val checkMiss = inputKey[Unit]("")
Global / localCacheDirectory := baseDirectory.value / "diskcache"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
checkMiss := {
val expected: Int = (Space ~> NatBasic).parsed
val s = streams.value

View File

@ -5,7 +5,7 @@ lazy val verify = "com.eed3si9n.verify" %% "verify" % "1.0.0"
Global / localCacheDirectory := baseDirectory.value / "diskcache"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
libraryDependencies += verify % Test
testFrameworks += new TestFramework("verify.runner.Framework")

View File

@ -3,7 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
name := "lib1"
organization := "com.example"
version := "0.1.0-SNAPSHOT"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
val publishRepoBase = settingKey[File]("Base directory for publish repo (HTTP server writes here)")
publishRepoBase := baseDirectory.value / "repo"

View File

@ -3,7 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
name := "lib1"
organization := "com.example"
version := "0.1.0-SNAPSHOT"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
// Use a fixed path for local ivy repo to avoid sbt 2.x output sharding
val ivyLocalBase = settingKey[File]("Local Ivy repository base")

View File

@ -1,7 +1,7 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / organization := "com.example"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "3.8.2"
ThisBuild / scalaVersion := "3.8.3"
val publishRepoBase = settingKey[File]("Base directory for Maven publish repo (HTTP server writes here)")
ThisBuild / publishRepoBase := (ThisBuild / baseDirectory).value / "repo"

View File

@ -3,7 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
name := "lib1"
organization := "com.example"
version := "0.1.0-SNAPSHOT"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
publishMavenStyle := true
val publishRepoBase = settingKey[File]("Base directory for Maven publish repo")

View File

@ -3,7 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
name := "lib1"
organization := "com.example"
version := "0.1.0-SNAPSHOT"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
// Publish to a file repo (tests ivyless publish without HTTP server)
val publishRepoBase = settingKey[File]("Base directory for publish repo")

View File

@ -1,9 +1,9 @@
lazy val a = project
.settings(
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
)
// (b / update) sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-reflect:3.8.2
// (b / update) sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-reflect:3.8.3
lazy val b = project
.dependsOn(a)
.settings(

View File

@ -2,7 +2,7 @@ import java.nio.file.Files
name := "clean-symlinks-test"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
TaskKey[Unit]("createSymlinkedDirectory") := {
IO.createDirectory(target.value)

View File

@ -1,9 +1,9 @@
> createSymlinkedDirectory
$ exists target/out/jvm/scala-3.8.2/clean-symlinks-test/foo/bar
$ exists target/out/jvm/scala-3.8.3/clean-symlinks-test/foo/bar
$ exists foo/bar
> clean
$ absent target/out/jvm/scala-3.8.2/clean-symlinks-test/foo
$ absent target/out/jvm/scala-3.8.3/clean-symlinks-test/foo
$ exists foo/bar

View File

@ -1,4 +1,4 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
organization := "com.example"

View File

@ -1,2 +1,2 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
publishLocal := {}

View File

@ -19,4 +19,4 @@ lazy val plugin = (projectMatrix in file("plugin"))
case _ => "2.0.0-RC3"
},
)
.jvmPlatform(scalaVersions = Seq("3.8.2", "2.12.21"))
.jvmPlatform(scalaVersions = Seq("3.8.3", "2.12.21"))

View File

@ -1,4 +1,4 @@
ThisBuild / scalaVersion := "3.8.2"
ThisBuild / scalaVersion := "3.8.3"
name := "hello"
enablePlugins(JavaAppPackaging)
@ -6,7 +6,7 @@ enablePlugins(JavaAppPackaging)
lazy val check = taskKey[Unit]("")
check := {
val cmd = "target/out/jvm/scala-3.8.2/hello/universal/stage/bin/hello"
val cmd = "target/out/jvm/scala-3.8.3/hello/universal/stage/bin/hello"
val cmd0 =
if (sys.props("os.name").toLowerCase(java.util.Locale.ROOT).contains("windows"))
cmd + ".bat"

View File

@ -1,4 +1,4 @@
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
// addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.20")
libraryDependencies += Defaults.sbtPluginExtra("com.github.sbt" % "sbt-native-packager" % "1.11.4", "2", "3.8.2")
libraryDependencies += Defaults.sbtPluginExtra("com.github.sbt" % "sbt-native-packager" % "1.11.4", "2", "3.8.3")

View File

@ -1,6 +1,6 @@
lazy val `a + b` = "2.13.18"
// https://github.com/scala/scala3/blob/3.8.2/library/src/scala/reflect/NameTransformer.scala#L47-L64
// https://github.com/scala/scala3/blob/3.8.3/library/src/scala/reflect/NameTransformer.scala#L47-L64
lazy val ~=<>!#%^&|*/+-:\\?@ = "my-name"
scalaVersion := `a + b`

View File

@ -1,4 +1,4 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
@deprecated
def foo = true

View File

@ -1,4 +1,4 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
@deprecated
def foo = true

View File

@ -1,5 +1,5 @@
lazy val scala3_LTS = "3.3.5"
lazy val scala3_current = "3.8.2"
lazy val scala3_current = "3.8.3"
lazy val check = taskKey[Unit]("")
organization := "com.example"

View File

@ -1,4 +1,4 @@
> packageBin
$ exists target/**/app_3.3.5-0.1.0-SNAPSHOT.jar
$ exists target/**/app_3.8.2-0.1.0-SNAPSHOT.jar
> core3_8_2/check
$ exists target/**/app_3.8.3-0.1.0-SNAPSHOT.jar
> core3_8_3/check

View File

@ -1,4 +1,4 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
crossPaths := false
name := "definition-lib-forname-test"
version := "1.0"

View File

@ -1,6 +1,6 @@
lazy val a1 = settingKey[Boolean]("")
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
a1 := true
Compile / sourceGenerators += {

View File

@ -1 +1 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"

View File

@ -11,7 +11,7 @@ lazy val intsSetting2 = Def.setting {
Seq(1, 2, 3)
}
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
intsTask := Seq(1, 2, 3, 4, 5, 6, 7)
intsTask -= 3
@ -30,10 +30,10 @@ intsSetting -= intSetting2.value
intsSetting --= intsSetting2.value
intsFromScalaV := Seq(1, 2, 3, 4, 5, 6, 7)
intsFromScalaV -= { if scalaVersion.value == "3.8.2" then 3 else 5 }
intsFromScalaV --= { if scalaVersion.value == "3.8.2" then Seq(1, 2) else Seq(4) }
intsFromScalaV -= { if scalaVersion.value == "3.8.2" then Option(6) else None }
intsFromScalaV --= { if scalaVersion.value == "3.8.2" then Option(7) else None }
intsFromScalaV -= { if scalaVersion.value == "3.8.3" then 3 else 5 }
intsFromScalaV --= { if scalaVersion.value == "3.8.3" then Seq(1, 2) else Seq(4) }
intsFromScalaV -= { if scalaVersion.value == "3.8.3" then Option(6) else None }
intsFromScalaV --= { if scalaVersion.value == "3.8.3" then Option(7) else None }
intsSetSetting := Set(1, 2, 3, 4, 5, 6, 7)
intsSetSetting -= 3

View File

@ -1 +1 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"

View File

@ -1,6 +1,6 @@
val scalatest = "org.scalatest" %% "scalatest" % "3.2.19"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
Test / fork := true
libraryDependencies += scalatest % Test

View File

@ -1,6 +1,6 @@
val munit = "org.scalameta" %% "munit" % "1.0.4"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
libraryDependencies += munit % Test
Test / fork := true

View File

@ -1,5 +1,5 @@
val scalatest = "org.scalatest" %% "scalatest" % "3.2.19"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
fork := true
libraryDependencies += scalatest % Test

View File

@ -1,3 +1,3 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
libraryDependencies += "com.eed3si9n.verify" %% "verify" % "1.0.0" % Test
testFrameworks += new TestFramework("verify.runner.Framework")

View File

@ -1,5 +1,5 @@
val munit = "org.scalameta" %% "munit" % "1.0.4"
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
lazy val root = rootProject
.settings(

View File

@ -6,7 +6,7 @@ val marker = new File("marker")
val check = TaskKey[Unit]("check", "Check correct error has been returned.")
val scalatest = "org.scalatest" %% "scalatest" % "3.2.19"
ThisBuild / scalaVersion := "3.8.2"
ThisBuild / scalaVersion := "3.8.3"
lazy val root = (project in file(".")).
settings(

View File

@ -67,7 +67,7 @@ final class SbtHandler(remoteSbtCreator: RemoteSbtCreator) extends StatementHand
} catch {
case _: IOException => process.destroy()
} finally {
if (process.isAlive) process.destroy()
if (process.isAlive()) process.destroy()
RunningProcesses.remove(process)
}
}

View File

@ -1,4 +1,4 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
val printCurrentProject = taskKey[Unit]("Prints current project name")

View File

@ -1,4 +1,4 @@
scalaVersion := "3.8.2"
scalaVersion := "3.8.3"
TaskKey[Unit]("willSucceed") := println("success")

View File

@ -78,7 +78,7 @@ class ChannelCursorTest extends AbstractServerTest {
@tailrec def impl(): Boolean =
lines.poll(deadline.timeLeft.toMillis, TimeUnit.MILLISECONDS) match {
case null => false
case s => if (!f(s) && !deadline.isOverdue) impl() else !deadline.isOverdue()
case s => if (!f(s) && !deadline.isOverdue()) impl() else !deadline.isOverdue()
}
impl()
}

View File

@ -192,15 +192,15 @@ case class TestServer(
hostLog(s"wait $duration until the server is ready to respond")
val deadline = duration.fromNow
var nextLog = 10.seconds.fromNow
while (portfileIsEmpty() && !deadline.isOverdue && process.isAlive) {
if (nextLog.isOverdue) {
while (portfileIsEmpty() && !deadline.isOverdue() && process.isAlive()) {
if (nextLog.isOverdue()) {
hostLog("waiting for the server...")
nextLog = 10.seconds.fromNow
}
Thread.sleep(10) // Don't spam the portfile
}
if (deadline.isOverdue) sys.error(s"Timeout. $portfile is not found.")
if (!process.isAlive) sys.error(s"Server unexpectedly terminated.")
if (deadline.isOverdue()) sys.error(s"Timeout. $portfile is not found.")
if (!process.isAlive()) sys.error(s"Server unexpectedly terminated.")
}
waitForPortfile(1.minute)
@ -254,18 +254,18 @@ case class TestServer(
"""{ "jsonrpc": "2.0", "id": 9, "method": "sbt/exec", "params": { "commandLine": "shutdown" } }"""
)
val deadline = 5.seconds.fromNow
while (!deadline.isOverdue && process.isAlive) {
while (!deadline.isOverdue() && process.isAlive()) {
Thread.sleep(10)
}
// We gave the server a chance to exit but it didn't within a reasonable time frame.
if (deadline.isOverdue && process.isAlive) {
if (deadline.isOverdue() && process.isAlive()) {
process.destroy()
val newDeadline = 10.seconds.fromNow
while (!newDeadline.isOverdue && process.isAlive) {
while (!newDeadline.isOverdue() && process.isAlive()) {
Thread.sleep(10)
}
}
if (process.isAlive) throw new IllegalStateException(s"process $process failed to exit")
if (process.isAlive()) throw new IllegalStateException(s"process $process failed to exit")
} finally {
readThread.interrupt()
/*
@ -309,7 +309,7 @@ case class TestServer(
@tailrec def impl(): Boolean =
lines.poll(deadline.timeLeft.toMillis, TimeUnit.MILLISECONDS) match {
case null => false
case s => if (!f(s) && !deadline.isOverdue) impl() else !deadline.isOverdue()
case s => if (!f(s) && !deadline.isOverdue()) impl() else !deadline.isOverdue()
}
impl()
}
@ -336,7 +336,7 @@ case class TestServer(
case Success(value) =>
value
case Failure(exception) =>
if (deadline.isOverdue) {
if (deadline.isOverdue()) {
val ex = new TimeoutException()
ex.initCause(exception)
throw ex
@ -357,8 +357,8 @@ case class TestServer(
case s =>
val s1 = s
val correctId = s1.contains("\"id\":\"" + id + "\"")
if (!correctId && !deadline.isOverdue) impl()
else if (deadline.isOverdue)
if (!correctId && !deadline.isOverdue()) impl()
else if (deadline.isOverdue())
throw new TimeoutException()
else s
}

View File

@ -45,7 +45,9 @@ object Test extends std.TaskExtra:
lazy val d3 = t3(a, b, c).flatMapR(f3)
def d4(i: Int): Task[Int] = nop flatMap { _ =>
val x = math.random; if (x < 0.01) task(i); else d4(i + 1)
val x = math.random()
if (x < 0.01) task(i)
else d4(i + 1)
}
def go(): Unit = {

View File

@ -66,17 +66,19 @@ trait Init:
def values: Iterable[Any] = data.values
def get[A](key: ScopedKey[A]): Option[A] =
delegates(key).flatMap(data.get).nextOption.asInstanceOf[Option[A]]
delegates(key).flatMap(data.get).nextOption().asInstanceOf[Option[A]]
def definingKey[A](key: ScopedKey[A]): Option[ScopedKey[A]] =
delegates(key).find(data.contains)
def getKeyValue[A](key: ScopedKey[A]): Option[(ScopedKey[A], A)] =
delegates(key).flatMap { k =>
data.get(k) match
case None => None
case Some(v) => Some(k -> v.asInstanceOf[A])
}.nextOption
delegates(key)
.flatMap { k =>
data.get(k) match
case None => None
case Some(v) => Some(k -> v.asInstanceOf[A])
}
.nextOption()
def getDirect[A](key: ScopedKey[A]): Option[A] = data.get(key).asInstanceOf[Option[A]]