-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Compiler version
3.3.6
Minimized code
If I remove the ()
, it then compiles error.
//> using scala "3.3.6"
import java.util.concurrent.{ CompletionStage, TimeoutException }
import scala.concurrent.duration.FiniteDuration
def scheduleOnce(delay: java.time.Duration, runnable: Runnable): Unit = ???
def scheduleOnce(delay: FiniteDuration, runnable: Runnable): Unit = ???
def scheduleOnce(delay: FiniteDuration)(f: => Unit): Unit = ???
def timeoutCompletionStage[T](duration: java.time.Duration)(value: => CompletionStage[T]): Unit = {
val stage = value
val p = new java.util.concurrent.CompletableFuture[T]
scheduleOnce(
duration,
() => {
p.completeExceptionally(new TimeoutException(s"Timeout of $duration expired"))
stage.toCompletableFuture.cancel(true)
}
)
}
Output
[error] -- [E134] Type Error: /Users/hepin/IdeaProjects/pekko/actor/src/main/scala/org/apache/pekko/pattern/FutureTimeoutSupport.scala:141:26
[error] 141 | val timeout = using.scheduleOnce(duration,
[error] | ^^^^^^^^^^^^^^^^^^
[error] |None of the overloaded alternatives of method scheduleOnce in trait Scheduler with types
[error] | (delay: java.time.Duration, runnable: Runnable)
[error] | (implicit executor: scala.concurrent.ExecutionContext):
[error] | org.apache.pekko.actor.Cancellable
[error] | (delay: scala.concurrent.duration.FiniteDuration, runnable: Runnable)
[error] | (implicit executor: scala.concurrent.ExecutionContext):
[error] | org.apache.pekko.actor.Cancellable
[error] | (delay: scala.concurrent.duration.FiniteDuration)
[error] | (f: => Unit)
[error] | (implicit executor: scala.concurrent.ExecutionContext):
[error] | org.apache.pekko.actor.Cancellable
[error] | (delay: java.time.Duration, receiver: org.apache.pekko.actor.ActorRef,
[error] | message: Any, executor: scala.concurrent.ExecutionContext, sender:
[error] | org.apache.pekko.actor.ActorRef): org.apache.pekko.actor.Cancellable
[error] | (delay: scala.concurrent.duration.FiniteDuration,
[error] | receiver: org.apache.pekko.actor.ActorRef, message: Any)
[error] | (implicit executor: scala.concurrent.ExecutionContext, sender:
[error] | org.apache.pekko.actor.ActorRef): org.apache.pekko.actor.Cancellable
[error] |match arguments ((duration² : java.time.Duration), () => Boolean)
[error] |
[error] |where: duration is a package in package scala.concurrent
[error] | duration² is a parameter in method timeoutCompletionStage
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Expectation
It should compile, or just gives expect () => Unit
of runnable ,but got () => Boolean
,