-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
compat:javaitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymorestat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label
Description
Based on the OpenCB failures found in following projects:
apache/pekko-http
- build logsakka/akka-http
- build logsapache/pekko-connectors
- build logsakka/akka
apache/pekko
Compiler version
Last good release: 3.8.0-RC1-bin-20250921-834e8e9-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250922-9bd7774-NIGHTLY
Bisect points to: f4330f0 (most likely related to the new stdlib)
Minimized code
final class Flow[In, Out]:
def collect[T](pf: PartialFunction[Out, T]): Flow[In, T] = ???
object Flow:
def create[T](): Flow[T, T] = ???
abstract class Message:
def asTextMessage: TextMessage
abstract class TextMessage extends Message
abstract class JavaPartialFunction[A, B] extends PartialFunction[A, B]:
@throws(classOf[Exception]) // required, compiles without annotation
def apply(x: A, isCheck: Boolean): B
final def isDefinedAt(x: A): Boolean = ???
final override def apply(x: A): B = ???
final override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = ???
public class JavaTestServer {
public static Flow<Message, Message> greeter() {
return Flow.<Message>create()
.collect(
new JavaPartialFunction<Message, Message>() {
@Override
public Message apply(Message msg, boolean isCheck) throws Exception {
if (isCheck) throw new RuntimeException();
else return handleTextMessage(msg.asTextMessage());
}
});
}
public static TextMessage handleTextMessage(TextMessage msg) {
return null;
}
}
Output
Compiling project (Scala 3.8.0-RC1-bin-20251004-9f70200-NIGHTLY, JVM (21))
[error] ./JavaTestServer.java:5:57
[error] error: name clash: compose(scala.Function1<A#1,Message>) in Function1 and compose(scala.Function1<A#2,A#2>) in JavaPartialFunction have the same erasure, yet neither overrides the other
[error] new JavaPartialFunction<Message, Message>() {
[error] ^
Warning: javac exited with exit code 1
scala-cli trimmed the output, here's the full, original output:
[error] /build/repo/http-core/src/test/java/org/apache/pekko/http/JavaTestServer.java:69:57: <R>compose(scala.PartialFunction<R,T1>) in scala.runtime.AbstractPartialFunction cannot implement <R>compose(scala.PartialFunction<R,A>) in scala.PartialFunction
[error] return type scala.PartialFunction<R,R> is not compatible with scala.PartialFunction<R,org.apache.pekko.http.javadsl.model.ws.Message>
[error] {
[error] @Override
[error] public Message apply(Message msg, boolean isCheck) throws Exception {
[error] if (isCheck)
[error] if (msg.isText()) return null;
[error] else throw noMatch();
[error] else return handleTextMessage(msg.asTextMessage());
[error] }
[error] }
[error]
Notes
Original code refered to scala.runtime.AbstractPartialFunction
(which is unsafe) but the same error can be reproduced when refering to public scala.PartialFunction
Expectation
Should compile
Metadata
Metadata
Assignees
Labels
compat:javaitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymorestat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label