title: Accessing fields of trait of an object instance
body: <p>I created this little Scala worksheet about inheritance and traits in Scala. As far as I understood, one is able to add traits to single object instances and access the methods of said trait in through that object.
  So I mixed in Parents with the f4 object of sister, yet I can't access the methods of Parents. The same goes for f1 and Grandparents.</p>
  <pre><code>abstract class FamilyMember(name: String, birthDate: String, placeOfBirth: String) {
    override def toString: String = this.name;
  }
  
  trait Parents extends FamilyMember{
    var children: Array[FamilyMember] = new Array[FamilyMember](0);
    def printChildren(): Unit = for (child &lt;- children ) println(child.toString)
    def isParent(): Boolean = true
  }
  
  trait GrandParents extends Parents {
    def printGrandChildren(): Unit = for (child &lt;- children; child2 &lt;- child.asInstanceOf[Parents].children) println(child2.toString)
  }
  
  class Mother(name: String, birthDate: String, placeOfBirth: String) extends FamilyMember(name, birthDate, placeOfBirth) with Parents {
  }
  
  class Sister(name: String, birthDate: String, placeOfBirth: String) extends FamilyMember(name, birthDate, placeOfBirth) {
  }
  
  val f1: Mother = new Mother(&quot;Hildegard&quot;, &quot;23-7-1952&quot;, &quot;Berlin&quot;) with GrandParents
  val f4: Sister = new Sister(&quot;Moni&quot;, &quot;19-12-1993&quot;, &quot;Frankfurt am Main&quot;) with Parents
  val f5: Sister = new Sister(&quot;Anne&quot;, &quot;10-12-2012&quot;,&quot;Berlin&quot;)
  
  //works fine:
  f1.isParent
  f1.children = f1.children :+ f4
  
  //doesn't work:
  f4.isParent
  f4.children = f5.children :+ f5
  f4.printChildren()
  f1.printGrandChildren()
  </code></pre>
  <p>The error I get:</p>
  <pre><code>Error:(30, 4) value isParent is not a member of Sister
  f4.isParent
  </code></pre>
  <p>But I added it, with the trait.</p>