Can you extend a typealias of a type nested in a generic type?

Hi all,

I was hoping to understand why the following doesn't work a little better:

struct Foo<T: Hashable> {
  struct Bar {}
  typealias Baz = Bar
}

extension Foo.Bar {} // ✅
extension Foo.Baz {} // 🛑 Reference to generic type 'Foo' requires arguments in <...>

// alternatively
struct Foo2<T: Hashable> { typealias Bar = Foo<T>.Bar }

extension Foo2.Bar {} // 🛑 Reference to generic type 'Foo2' requires arguments in <...>

I can appreciate why it's not working, however, I was more wondering how to describe it. I had a bit of a look through the GenericsManifesto.md as well as some proposals but nothing jumped out at me.

  • Is there a way to describe what I'm trying to do?
  • Is there a different way to express what I'm trying to do?
  • Is this something that could/should be possible?

Thanks for any input.

3 Likes