How to access Abstract Class fields from a Class that doesn't extend it?

Hello, I have an abstract class that I need to get its field to use on my decorator classes.

  //methods are overriden in concrete componenets
abstract class AbstractStructs[A](implicit val ordng: Ordering[A]) extends Collection[A] {
  protected var elements: List[A] = Nil

trait Collection[A] {

  def push(element: A): Boolean

  def pop(): Option[A]

  def peek(): Option[A]

  def size: Int = 0

  //concrete component
class FIFOStruct[Int] extends AbstractStructs[Int]{

  override def push(element: A): Boolean //implementation

  override def pop(): Option[A] //implementation

  override def peek(): Option[A] //implementation

  override def size: Int = 0 //implementation

  //struct decorator

abstract class StructDecorator[A](struct: Collection[A]) extends Collection[A]{

  override def push(element: A): Boolean = {
    struct.push(element: A)

  override def pop(): Option[A] = {

  override def peek(): Option[A] = {

  override def size: Int = struct.size

  //decorator for one of features
class PrimeDecorator[A](struct: Collection[A]) extends CollectionDecorator[A](struct){

override def push(element: A): Boolean = {

//method I create to compare for primes, needs access to elements field of Abstract Class AbstractStructs for comparison
def compare(elem: A, list: List[A]): Boolean = {


//need to check method here, but "cannot resolve symbol elements"
if (prime(element, elements)) false


Creating an instance of the abstract class will make me import all the methods twice which I don’t want. I must use the field protected var elements: List[A] = Nil

How can I access it?

This code is already broken with the PrimeDecorator#push() implementation excluded. Remove this implementation and make sure that the remaining code compiles - use the ??? operator for not yet implemented methods. Consider using scastie for longer code snippets, as suggested in a previous thread.

As for PrimeDecorator: What exactly needs to be implemented? What is the original problem statement?

The push() method works, I had another decorator with capacity that uses super.push() and works just fine. The problem here is the elements variable I can’t access. A workaround I did is putting the compare() in all 3 concrete components, but that’s just dumb.

I basically need to implement everything from last thread but convert them to decorator pattern.