class nestedProduct<T> { enum Gadget { case smartphone case laptop case frIDge case others(T) } enum Company { case Samsung case Apple case Sony case others(T) } let company: Company let gadget: Gadget let revIEws: [T] init(enterCompany: Company,enterGadget: Gadget,enterReVIEw: [T]) { company = enterCompany gadget = enterGadget revIEws = enterReVIEw }}
现在,我尝试初始化
let product = nestedProduct<String>(enterCompany: nestedProduct.Company.Apple,enterGadget: nestedProduct.Gadget.laptop,enterReVIEw: ["Good"])
但是,我收到一条错误消息,
GenericCache(0x11102a518): cyclic Metadata dependency detected,aborting
我不知道为什么会这样.你能帮忙吗?谢谢!
看起来这是一个已知问题: https://bugs.swift.org/browse/SR-3779但是,我能够通过将枚举标记为间接来避免这种情况.这会将相关值存储在另一个破坏循环依赖关系的地方.
indirect enum Gadget { case smartphone case laptop case frIDge case others(T)}indirect enum Company { case Samsung case Apple case Sony case others(T)}总结
以上是内存溢出为你收集整理的Swift 3.1嵌套泛型Bug与循环元数据全部内容,希望文章能够帮你解决Swift 3.1嵌套泛型Bug与循环元数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)