Reputation: 806
I am trying to create a 2nd constructor and call the parent class with a different generic type based on the constructor invocation. 1 type is GroupTrackInfoDTO and the other one is TrackInfoDTO but I keep getting a compiling error
Platform declaration clash: The following declarations have the same JVM signature
My code:
class GetSettingsTask
: BizOperationTask {
private var mCallback: BizTaskCallback<TrackSettings>? = null
constructor(operation: BizOperation<GroupTrackInfoDTO>, mCallback: BizTaskCallback<TrackSettings>) : super(operation) {
this.mCallback = mCallback
}
constructor(o: BizOperation<TrackInfoDTO>, mCallback: BizTaskCallback<TrackSettings>) : super(o) {
this.mCallback = mCallback
}
if I add a dummy parameter to one of the constructors it worked but no idea why
constructor(o: BizOperation<TrackInfoDTO>, mCallback: BizTaskCallback<TrackSettings>, i: Int = 0) : super(o) {
this.mCallback = mCallback
}
Upvotes: 0
Views: 44
Reputation: 5329
They are the same JVM signature. You can define an abstract class (AbstractTrackInfoDTO
) that is the parent of TrackInfoDTO
and GroupTrackInfoDTO
then declare the constructor as below:
constructor(operation: BizOperation<AbstractTrackInfoDTO>, mCallback: BizTaskCallback<TrackSettings>) : super(operation) {
this.mCallback = mCallback
}
Upvotes: 1