How to access a Java inherited field with the same name as a Scala method?

会有一股神秘感。 提交于 2020-01-06 07:25:11

问题


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?

来源:https://stackoverflow.com/questions/17557642/how-to-access-a-java-inherited-field-with-the-same-name-as-a-scala-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!