How to access a Java inherited field with the same

2019-09-06 17:42发布

I'm having a Scala trait A with an abstract method

trait A[T] {
  def self: T
}

Now it happened me that I want to extends a Java class not under my control with a field with the same name:

public class B<T> {
    protected T self;
}

I'd like to have a class C defined like

class C[T] extends B[T] with A[T] {
    override def self: T = /* the field `self` of `B` ??? */
}

Is it possible to access the field B.self somehow so that it doesn't resolve to the method A.self instead? Is it even possible to have a scenario like that?

0条回答
登录 后发表回答