'The way to differ two functions with the same name in available scope in Scala

I have a pretty straightforward example, but in the same time it is confused. It is shown below:

abstract class AbstractClass[A] {

  def function1(elem: A)(f: A => A): AbstractClass[A]
  
  object AbstarctClass {
    def function2(f: A => A) = new AbstractClass[A] {
      override def function1(elem: A)(f: A => A): AbstractClass[A]  = 
        // some code
    }
  }
}

Is there way to differ two functions, that receives function1 and function2, in scope of function1? I know, we can call them in different way and they will be used properly, but I'm interested how can we differentiate them in this case?



Solution 1:[1]

Update parent class declaration:

abstract class AbstractClass[A] { parent =>
  // ...
}

Then

parent.function1(..)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cchantep