title: Inheriting class with primary constructor
body: <p>I have a parent class as following,</p>
  
  <pre><code>interface ITask { }
  
  open class Task(val targetServer: Server) : ITask { }
  </code></pre>
  
  <p>Then there a child inheriting it and overriding the primary constructor as following,</p>
  
  <pre><code>data class FileTask(val sourceServer: Server, targetServer: Server) : Task(targetServer = targetServer) {
  
  }
  </code></pre>
  
  <p>This is throwing a compilation error in eclipse as </p>
  
  <blockquote>
    <p>Data class primary constructor must have only property (val / var) parameters</p>
  </blockquote>
  
  <p>Removing the  <code>data</code> keyword from the class header will kill the error,  but I don't understand why.</p>
  
  <p>Keeping the <code>data</code> keyword and adding <code>var</code> to the <code>targetServer</code>  gives another error </p>
  
  <blockquote>
    <p>'targetServer' hides member of supertype 'Task' and needs 'override' modifier</p>
  </blockquote>
  
  <p>Adding <code>override</code> to the <code>targetServer</code> to be <code>override var targetServer: Server</code> throws another error </p>
  
  <blockquote>
    <p>'targetServer' in 'Task' is final and cannot be overridden</p>
  </blockquote>
  
  <p>I need some help to understand these errors.</p>