Question: I have abstract class Person and two traits Employee and Student

```
abstract class Person(val name: String) {
  val tax: Double
}

trait Employee {
  val salary: Double;
  lazy val tax: Double = salary * 0.1;
}

trait Student {
  val tax: Double = 0.0;
}

```

And i need to create 2 instances using these two traits

```
studentEmployee = new Person("John") with Student with Employee {override var salary: Double = 1000};
employeeStudent = new Person("Mike") with Employee with Student {override var salary: Double = 1000};

```

I get error: 

> 
> ...inherits conflicting members: lazy value tax in trait Employee of type Double and value tax in trait Student of type Double ...
> 
> 
> 

How can I use two traits with fields with the same name?

Answer: 
The ideal way is to create a separate Trait for tax called `Tax` and extend the `Employee` and `Student` from this Base trait. Traits ideally should act like an interface and should not have the actual implementation. The implementation should be part of the class that extends this traits.

The below implementation takes care of this 

```
abstract class Person(val name: String) {
}

trait Tax {
    val tax: Double

}
trait Employee extends Tax {
  val salary : Double;
  override val tax : Double ;
}

trait Student extends Tax {
  override val tax : Double;
}

var studentEmployee = new Person("John") with Student with Employee {
                   override val salary: Double = 1000;
                   override val tax = salary * 0.1};

var employeeStudent = new Person("Mike") with Employee with Student {
                  override val salary: Double = 1000 ;
                  override val tax = 0.0};

scala> studentEmployee.tax
res42: Double = 100.0

scala> employeeStudent.tax
res43: Double = 0.0

```
The first problem is here that you are trying to override `val` with `var` and the second problem is called diamond problem. The problem can be solved as follows:

```scala
abstract class Person(val name: String) {
  val tax: Double
}

trait Employee {
  var salary: Double
  val tax: Double = salary * 0.1
}

trait Student {
  val tax: Double = 0.0
}

val studentEmployee = new Person("John") with Student with Employee {
override val tax = 2.0
  override var salary: Double = 1000
}
val employeeStudent = new Person("Mike") with Employee with Student {
  override val tax = 2.0
  override var salary: Double = 1000
}

```

You can find here similar problem solution: <http://eed3si9n.com/curious-case-of-putting-override-modifier>

And you can read more about linearization here: <http://eed3si9n.com/constraining-class-linearization-in-Scala>
And here: <https://www.artima.com/scalazine/articles/stackable_trait_pattern.html>