pjfanning opened a new pull request, #3718: URL: https://github.com/apache/pekko/pull/3718
### Motivation Java generics are invariant, so the stream-typed javadsl factories reject pre-typed function values a Java user would reasonably pass, for example a `Function<Object, String>` as the failure function of `ActorSink.actorRef`, or a `Function2<Object, ActorRef<Reply>, Asking>` for `ActorFlow.ask`. Lambdas adapt to the target type, but variables, fields and method references do not. This is the stream-typed item of "3. Function parameters in the other modules' javadsl" in [[#3712 (comment)](https://github.com/apache/pekko/issues/3712#issuecomment-6439498835)](https://github.com/apache/pekko/issues/3712#issuecomment-6439498835). ### Modification - `ActorFlow.ask`, `askWithStatus`, `askWithContext`, `askWithStatusAndContext`: `makeMessage` takes `Function2[? >: I, ? >: ActorRef[..], ? <: Q]`. - `ActorSink.actorRef` and both `actorRefWithBackpressure` overloads: `onFailureMessage` takes `Function[? >: Throwable, ? <: T/M]`; `messageAdapter` and `onInitMessage` are widened the same way. - `ActorSource.actorRef` and `actorRefWithBackpressure`: matchers take `Predicate[? >: T]` and `Function[? >: T, ? <: Optional[? <: ..]]`. - Add MiMa excludes for the generic signature changes. Not changed: `ActorFlow.ask(parallelism, ref, timeout, makeMessage)`, which takes a Scala function type rather than a `japi.function`, and the other modules listed in the issue (persistence-typed, actor-typed, actor-testkit-typed, cluster-typed). ### Result Java callers can pass these values without casts or re-typing. Erasure is unchanged for every method, so this should be binary compatible; only `IncompatibleSignatureProblem` excludes are needed. ### Tests - New Java compile tests in `ActorSourceSinkCompileTest` and `ActorFlowCompileTest` that pass values the old signatures rejected. - **Not run locally**: this change was prepared in a sandbox that cannot reach Maven Central, so `sbt compile`, the tests, `sbt +mimaReportBinaryIssues`, `scalafmt` and `javafmtAll` were not run. This PR is a draft so CI can be the first full check. Expect possible follow-up fixes for Scala 2.13/3 compilation of the wildcard types, formatting, and MiMa. ### References Refs #3712. Follows #3713 and #3714. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
