我遇到了一些泛型问题。
我有:
class SyncRequest<Type>: ApiRequest<Type> where Type:SyncableModel {} // really empty. Used only for tipisation
class SyncableModel: BaseModel {...} // BaseModel is class also
class SyncServiceImpl: SyncService {
private var registeredRequests: [SyncRequest<SyncableModel>]
init() {
registeredRequests.append(SyncRequest<EventGroup>("{somepath}"))
}
}
但是有一个错误说
&#34;无法转换类型&#39; SyncRequest&lt; .EventGroup&gt;&#39;的值预期 参数类型&#39; SyncRequest&lt; .SyncableModel&gt;&#39;&#34;
有没有办法将子类用作泛型类型?