Follow-up on recent posts in the second pitch thread:
One of the limitations of @implementation
is that it has the same "view" of the imported class as any other Swift code would, so it's not possible to import the code with lightweight generics in other code but without it for @implementation
. (Except by playing games with different header content, I suppose, though clang modules intentionally don't make that easy to do.)
Ultimately, I do think @implementation
could support lightweight generics, although it might require changing the way all Swift code imports them. It's just an especially complex problem that's only necessary for a very small number of classes, so I chose to subset it out.
I think the compiler will always be able to infer this correctly. When @implementation
is applied to an extension
, it can infer it from the type being extended; if @implementation
is eventually applied to other declarations, it can infer it from other attributes applied to the declaration (@objc
, @_cdecl
, @_expose(Cxx)
).