Protocol extension triggers segfault

I haven't seen this specific pattern of protocol extension elsewhere, but it works in a playground and does what I need it to do — extending one protocol to provide an implementation of another protocol it inherits with typealias requirements. Simple example:


protocol TreeNode: SequenceType {
    var children: Array<Self> { get set }
}
extension SequenceType where Self: TreeNode, Generator == AnyGenerator<Self> {
    func generate() -> Generator {
        return anyGenerator(children.generate())
    }
}


Issue comes when it's dropped into a project. If it's the only thing in the project, it'll compile fine. However, I can drop seemingly innocuous code (not in any way interacting with the above) into another file and the project segfaults on compile.


Example of innocuous code for another file:


struct IntWrapper {
    let anInt: Int = 0
}


This compiles fine without the presence of the above.


Better way to accomplish the same? Suggestions for troubleshooting the segfault?

I think we just haven't implemented this properly yet—even if it compiles in one file, it may not work correctly at runtime. Please file a bug.

rdar://22093958


Thanks.

I can't reproduce this with XCode 7 Beta 5.


What I would like to understand is why you're choosing to extend `SequenceType`. Wouldn't it be much simpler if the `generate` method was added via an extension of `TreeNode`?


extension TreeNode where Generator == AnyGenerator<Self> {
  func generate() -> Generator {
    return anyGenerator(children.generate())
  }
}
Protocol extension triggers segfault
 
 
Q