[swift-evolution] Allow a typealias to be named after the corresponding type

Tim Vermeulen tvermeulen at me.com
Sat Jun 18 18:39:27 CDT 2016


This doesn’t work if `DataStructureKit` and `BinarySearchTree` have the same name.

> > 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>
> 
> --
> Brent Royal-Gordon
> Architechies
> 
> 
> 
> 


More information about the swift-evolution mailing list