> On 15 Jun 2016, at 09:35, Brent Royal-Gordon via swift-evolution > <swift-evolution@swift.org> wrote: > >> public struct BinarySearchTree<Key: Comparable, Value> { >> typealias Node = Node<Key, Value> >> var root: Node? >> } >> >> private class Node<Key: Comparable, Value> { } >> >> This code currently doesn’t compile because the Node typealias circularly >> references itself. I’d like this syntax to just work, because this are the >> alternatives: >> - rename the typealias to something like `TheNode` >> - rename the Node class >> - don’t use a typealias at all > > - fully qualify the class name with the name of the module: > > typealias Node = DataStructureKit.Node<Key, Value>
This. Though I do sympathise with the issue, as it’s kind of strange that a circular reference is assumed rather than searching for something else in scope, as this differs from how things like variable shadowing behave. That said, I think fully qualifying the type is the right solution in this case, but I wonder if we might consider a fixit capable of suggesting possible matching types? _______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution