Swift 3 嵌套通用编译器崩溃



我找到了这个链接(swift 3 中的嵌套泛型(解决了我的一个问题,但现在问题是当我尝试使用嵌套泛型从 UIView 继承时(在这种情况下(编译器崩溃。

class BaseModel {}
class BaseVM<T: BaseModel> {}
class BaseService<T: BaseModel, U: BaseVM<T>> : UIView {
   //init viewmodel with generic model
}
class Human : BaseModel {
   var name = ""
}
class HumanVM: BaseVM<Human> {
   var name = ""
   init(model : Human) {
      super.init()
      name = model.name
   }
}
class HumanService: BaseService<Human, HumanVM> {}

这种特定的代码: UIView使编译器崩溃。这是一个限制吗?或者也许我做错了什么。

编辑:它适用于Swift 3.1测试版。

它适用于 Swift 3.1 测试版

然后使用 Swift 3.1 beta (Xcode 8.3(。它引入了许多新的嵌套泛型功能,并修复了许多与泛型有关的编译器错误。

最新更新