Closed
Description
see original forum post reported by @mdedetrich
Compiler version
3.3.0
Minimized code
package pekko
// package org.apache.pekko.japi.function
@FunctionalInterface
trait Function[-T, +R] extends java.io.Serializable {
@throws(classOf[Exception])
def apply(param: T): R
}
// package org.apache.pekko.javadsl
final class Source[Out, Mat]() {
def mapConcat[T](f: pekko.Function[Out, _ <: java.lang.Iterable[T]]): Source[T, Mat] =
???
}
// package com.google.pubsub.v1
final class ReceivedMessage
// package com.google.pubsub.v1
final class StreamingPullResponse {
def getReceivedMessagesList: java.util.List[ReceivedMessage] = ???
}
// package example
class Materialised
// package example
object Test {
val streamingPullResult: Source[StreamingPullResponse, Materialised] = ???
def test =
streamingPullResult
.mapConcat(((response: StreamingPullResponse) => response.getReceivedMessagesList))
}
Output
Compiling project (Scala 3.3.0, JVM)
[error] ./foo.scala:37:21
[error] Found: pekko.StreamingPullResponse => java.util.List[pekko.ReceivedMessage]
[error] Required: pekko.Function[pekko.StreamingPullResponse, ? <: Iterable[T]]
[error]
[error] where: T is a type variable
[error] .mapConcat(((response: StreamingPullResponse) => response.getReceivedMessagesList))
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
adding the explicit type pekko.Function[StreamingPullResponse, java.util.List[pekko.ReceivedMessage]]
fixes the error,
also inference works if the signature of mapConcat changes to
def mapConcat[F[X] <: java.lang.Iterable[X], T](f: pekko.Function[Out, F[T]]): Source[T, Mat]
Expectation
it should compile, like it did in scala 2.13.10