Suppose I have a trait A and a class A1 that extends A:
trait A
class A1 extends A
and A1 has some unique property:
class A1 extends A { val hello = "hello" }
and I have a method that I want to handle all subclasses of trait A:
def handle:A = new A1
but, if I try to access unique properties defined in A1, understandably, it doesn't work:
scala> handle.hello
<console>:11: error: value hello is not a member of A
handle.hello
^
Once I'm done handling instances of subclasses of A as As, how do I once again access them with all their unique properties? How does this mechanism work?