Question: Let's say I have a simple trait called Constraint:

```
trait Constraint {

  def description: String

  def constraintValue: Int

  def applyConstraint
}

```

... and two classes that extend this trait:

```
class ConstraintA(val constraintValue: Int) extends Constraint {

  override def description: String = "CONSTRAINT_A"

  override def applyConstraint: Unit = {
    // ...
  }
}

class ConstraintB(val constraintValue: Int) extends Constraint {

  override def description: String = "CONSTRAINT_B"

  override def applyConstraint: Unit = {
    // ...
  }
}

```

I'm reading an XML file and instantiating a list of ConstraintA and Constraint B (the concrete implementations).

This is the code I use to read the file and create the list:

```
val xml = XML.loadFile(xmlFilePath)

val readConstraints = (xml \ "constraints") (0).attributes.map {
   c =>
     c.key match {
       case "CONSTRAINT_A" => new ConstraintA(c.value.text.toInt)
       case "CONSTRAINT_B" => new ConstraintB(c.value.text.toInt)
       case _ => Nil
     }
 }

```

The problem is that I want to return `List[Constraint]` but I get the error message: **Expression of type List[Object] doesn't conform to expected type List[Constraint]**.

Any hint on why the language does not infer the type?

Thanks!

Answer: 
The reason is that in your case `B` references (or as you will calls out to) `A`. There is no knowledge about `B` in `A`, so no arrow from A to B, but rather the other way around. 

The UML entity diagram is not about who 'gets' what, but rather about who references/knows about who.
Well, that's the way UML had been designed. The arrow points to the general class. The special one inherits and adds/replaces functionality.