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
}
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.