I'm trying to use the scaffolding described by oxbow_lakes in What is the easiest way to implement a Scala PartialFunction in Java? to call a Scala method that takes a PartialFunction. Here's my Scala code:
class MyScalaClass {
def instanceOfSomeType: SomeType = ...
def consume(processor: PartialFunction[SomeType, Unit]) {
processor.lift(instanceOfSomeType)
}
}
And here's how I'm trying to call it from Java:
MyScalaClass myScalaClass = new MyScalaClass();
PartialTransformer<SomeType, Unit> fn = new PartialTransformer<SomeType, Unit>() {
@Override public boolean isDefinedAt(SomeType input) { return true; }
@Override protected Unit transform0(SomeType input) { return null; }
};
PartialFunction<SomeType, Unit> partial = PartialFunctionBridge$.MODULE$.fromPartialTransformer(fn);
myScalaClass.consume(partial);
The compiler tells me:
consumeInt(scala.PartialFunction<SomeType,java.lang.Object>) in MyScalaClass cannot be applied
to (scala.PartialFunction<SomeType,scala.Unit>)