The main change here is to associate a witness table with a `ProtocolConformance` instead of a `RootProtocolConformance`.
A `ProtocolConformance` is the base class and can be a `RootProtocolConformance` or a `SpecializedProtocolConformance`.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.
Resolves rdar://121409846
Smaller values of FormalLinkage are actually wider scopes,
so std::min'ing with PublicUnique actually just gives you
a result that's always PublicUnique. And we need to start
with PublicNonUnique because even things derived solely
from uniquely-emitted types are not themselves generally
unique.
I don't want to immediately open the can of worms that fixing
this for everyone would entail, so I'm just adding the new
version in parallel and moving new clients to it gradually.
For `async` function types, an actor constraint can be enforced by the callee by hopping executors,
unlike with `sync` functions, so doesn't need to influence the outward type of the function.
rdar://76248452
- The overload of operator^ on FormalLinkage, while cute, was only used
in this one place, and does not behave like an XOR.
- The structural type walk was totally unnecessary in the first place,
because we were only ever calling getTypeLinkage() with builtin types
and nominal types.
- Furthermore, the structural type walk was doing the wrong thing with
nested nominal types, because the linkage of a nested type A.B
should not be the intersection of the linkage of A and A.B. If A is an
imported type and A.B is defined in an extension of A, we would give
the metadata of A.B shared linkage, which is wrong.
Don't hardcode linkage of default witness thunks, addressing a FIXME.
This will allow us to emit default witness thunks for requirements of
internal protocols, too.
Easy cut down on exported symbols. Unless a private type is referenced in
an inlineable function, there's no way to generate a reference to it
outside of the current file, except in the debugger. (That last bit is why
we can't use fully private linkage, which would keep the symbol out of the
symbol table completely.)
We should be doing this for "internal" declarations as well, but the
standard library /does/ have references to internal types in inlineable
functions, and also has tests that directly access these types.
Swift SVN r24838
Teach IRGen to honor the linkage of SILWitnessTables, and teach SILGen to emit witness tables and protocol witness thunks for external definitions with shared linkage. Fixes <rdar://problem/16264703>.
Swift SVN r14908
In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.
Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.
Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.
Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration. This computation should really take
advantage of the relationship between modules, but currently
it does not.
Swift SVN r12090