【问题标题】:Swift template library斯威夫特模板库
【发布时间】:2014-06-26 18:19:06
【问题描述】:

有人能描述一下这是怎么可能的吗:

swift模板库中有以下内容:

protocol Collection : Sequence {
     subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}

这没关系。

但是如果你写:

protocol Test : Sequence {
     subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}

有编译错误:

“IndexType”不是“Self”的成员类型

我可以通过以下方式修复此错误:

protocol Test : Sequence {
     typealias IndexType
     subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
}

但首先工作如何?

【问题讨论】:

    标签: ios swift ios8 sequence


    【解决方案1】:

    当您从模板库中看到某些内容时,您并没有看到原始源代码,而是看到了与原始源代码非常相似的反编译版本。这意味着有时它会丢失部分和/或由于其他原因无法编译。

    我希望 Apple 最终会修复它,以便在这种情况下也能显示 typealias,但不会赌它。

    您可以通过在http://bugreport.apple.com 提交错误报告来增加几率

    【讨论】:

      猜你喜欢
      • 2017-07-22
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      • 2017-11-13
      • 2015-08-19
      • 2014-09-11
      • 1970-01-01
      相关资源
      最近更新 更多