If I have the following class defined in java
public class A
{
protected class B
{
}
protected void method(B b) {...}
}
And I want to inherit from it in scala and override method. I would have hoped to do the following:
class C extends A {
override def method(b: B): Unit = {
// ... do something
super.method(b)
}
}
However the scala compiler does not like when I do it this way giving the following error:
method method overrides nothing. Note: the super classes of class C contain the following, non final members named method: protected[package ...] def method(x$1: A#B): Unit
The only way I can make it work is to do the following:
class C extends A {
override def method(b: A#B): Unit = {
// ... do something
super.method(b.asInstanceOf[this.B])
}
}
I find having to do this quite ugly and was wondering if there was a neater way of doing it?
Thanks
Des