It's now possible to have a base protocol that's less available
than one inheriting from it:
```
@available(macOS 200)
@reparentable public protocol P {}
public protocol Q: P {}
```
In this case, the protocol conformance descriptor for a client type
conforming to Q would contain in its resilient witnesses a base conformance
descriptor for Q conforming to P. That symbol (ending in 'Tb') won't be
available on older versions of the library. So, we choose to weak-link
that symbol (i.e., expect it to be extern_weak) in order to allow the client
targeting an older deployment target to still work.
This change forces you to write ``@reparented` relationships
on an extension of a protocol, rather than on the protocol
itself.
The ProtocolConformance needs to be associated with some
GenericContext and IRGen expects it to be an ExtensionDecl.
That environment defines under what conditions the conformance
exists. We also need to define witnesses for the new parent's
requirements in an extension anyway, so it's a natural fit.
The previous workaround for this was kind of awful, as it'd
require searching all the protocol's extensions and "guess"
which extension they want to represent the conformance. While
we could try to synthesize an extension, there's two
challenges there:
1. Due to SuppressedAssociatedTypes, it's not so simple to
synthesize an unconstrained ExtensionDecl.
2. We currently rely on same-type requirements to pin the
associated types to particular witnesses of those requirements
in the extension. So it's not purely unconstrained! For example,
```
extension Seq: @reparented BorrowSeq where Iter == MyIter {}
```
The constraints that are disallowed (but not yet diagnosed)
are conditional conformance requirements, as the default
conformance for a reparenting cannot depend on those.
Thus, it's better that programmers to specify the extension.
We generate public metadata lazily which implies it could be emitted into a
different module. If we emit metadata for a public type into a module
other than its "home module" apply "shared" linkage.
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
The asmname attribute allows one to specify the name that will be used
when lowering a given SIL declaration to LLVM IR. It is not currently
exposed in the surface language.
Make sure this attribute round-trips through the parser and
serialization.
Part of rdar://137014448O.
When Embedded Swift emits a symbol that was imported from another
module, ensure that the symbol is emitted as a weak definition. This
way, importing the same module (and using its symbol) into several
different modules doesn't cause duplicate-symbol errors at link time.
Rather, the linker will merge the different symbol definitions. This
makes Embedded Swift libraries work without resorting to
`-mergeable-symbols` or `-emit-empty-object-file`.
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`.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
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
Currently only arrays can be put into a read-only data section.
"Regular" classes have dynamically initialized metadata, which needs to be stored into the isa field at runtime.
Partially address the incorrect handling for the `#dsohandle` on
Windows.
We were previously emitting a local definition for this external
constant, and worse yet, not marking the definition for COMDAT. It is
unclear what definition would win ultimately (implementation defined),
as we had a definition as well as the linker synthesized value. We can
change the SIL linkage for this type to `DefaultForDeclaration` which
will give it `available_externally` and default visibility and storage
which is closer to what we desire. However, because we do not track the
LLVM variables and apply heuristics for lowering the
`SILGlobalVariable`, we would attribute it with imported DLL Storage.
This would then cause us to fail at link time (amusingly enough link.exe
will report a LNK1000). Special case the variable and track that we are
targeting a windows environment in the `UniversalLinkageInfo` so that we
do not special case this on other platforms.
This also has the nice side effect of allowing us to remove the special
case in the TBD handling.
Fixes: #64741