当我在一个通用的结构体中嵌套一个类,并尝试实现相等运算符,如下所示:
struct Outer<T> { class Inner : Equatable {} } @infix func == <T>(lhs: Outer<T>.Inner,rhs: Outer<T>.Inner) -> Bool { return lhs === rhs }
当我尝试运行该项目时,我收到以下错误:
While emitting IR SIL function @_TFCC4Test5Outer5InnerCU__fMS1_FT_S1_ for 'init' at .../Testing.swift:20:11 <unknown>:0: error: unable to execute command: Segmentation fault: 11 <unknown>:0: error: swift frontend command Failed due to signal (use -v to see invocation) Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift Failed with exit code 254
然而,当我做同样的事情没有嵌套类时,它工作正常:
class MyClass : Equatable {} @infix func == (lhs: MyClass,rhs: MyClass) -> Bool { return lhs === rhs }
这是编译器的错误,还是我做错了?
将泛型类型struct中的类或结构体嵌套现在被XCode6 Beta6标记为无效