o.semen
04/27/2018, 10:10 AMinterface TopicDelegate<T: ProfileItem> {
val title: Int
}
class DistrictDelegate(val api: INetworkApi): TopicDelegate<District> {
override val title: Int = R.string.choose_districts
}
abstract class TopicFragment<T: ProfileItem> : BaseFragment() {
private var modeDelegate: TopicDelegate<T> = DistrictDelegate(mNetworkApi) //does not work
//Type mismatch. Required: TopicDelegate<T> Found: DistrictDelegate
}
diesieben07
04/27/2018, 10:12 AMDistrictDelegate
is a TopicDelegate<District>
, but a TopicDelegate<T>
is required. T
might not be District
.o.semen
04/27/2018, 11:43 AMDistrict extends ProfileItem
so TopicDelegate<District>
should fit into TopicDelegate<T: ProfileItem>
right ?diesieben07
04/27/2018, 11:44 AMT
is a parameter, it may stand for anything that extends ProfileItem
. So if T
is actually a SomeOtherProfileItem
, you can't put a District
in there.