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