Ordinary base protocols use fixed-indexing to access the base index.
That means adding another base protocol to an existing protocol
can break the order of the entries, and thus clients, because we
otherwise order the base entires with TypeDecl::compare.
Reparentable protocols are meant to be resilient to that, so we
order them at the end of the base entries list, just before the
other resilient entries in the witness table.
This patch completes the picture, by having the reparentable
protocol entries be indexed resiliently, in the same manner as
associated conformances.
The difference is that we can skip the call to
`swift_getAssociatedConformanceWitness`
and compute the index directly by finding the distance of the
descriptors, because we know all base protocol witness table
entries are eagarly instantiated.
Using this distance protects us from the ordering problems
of entries among all of the reparentable base protocols.
resolves rdar://173409851
If an inheriting protocol IP declares a requirement that
exactly matches one in the reparentable protocol P, we cannot
consider it to be an override. They need to have independent
witness table entries in both IP and P.
Otherwise, reparenting IP would cause those overriding decls
to have witness table entries moved from IP to P, causing an
ABI break.
resolves rdar://171928937
The test is actually failing on Linux because there are symbols removed.
I'm not familiar enough with this test to fix it at the moment, so
disabling for now and listing the incorrect symbols.
These tests were disabled on everything except macOS because it relies
on flags that are specific to llvm-nm. This PR re-enables the tests and
uses the llvm-nm from the building toolchain to execute the test instead
of hoping that the nm on path is the llvm-nm.
It also removes the extra target-resilience-test-coroutine-accessors
expansion, which is only used in one test and instead adds the
CoroutineAccessor experimental feature flag to the test that needs it.
The only way to avoid a source break when introducing a
reparenting is to allow implied conditional conformance
to a @reparentable protocol, as prior code would not have
explicitly stated it.
We were walking the extensions of protocols in
requirement lowering and in getInheritedProtocols
to also count the @reparented entries in all
extensions. I had already seen some request
evaluator cycles triggered by this with objc
protocols, and it seems unnessecary as it's
actually a benefit to force people to write the
inheritance on the protocol itself.
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.
Their definition is fully visible to clients to be copied into them, and there isn't necessarily
a symbol for the property descriptor in the defining module, so it isn't necessary or desirable to
try to use a property descriptor with them. Trying to reference the descriptor leads to missing
symbol errors at load time when trying to use keypaths with older versions of the defining dylib,
which goes against the purpose of `@_alwaysEmitIntoClient` meaning "no ABI liabilities for the
defining module". Fixes rdar://94049160.
The runtime that shipped with Swift 5.1 and earlier had a bug that interfered with backward
deployment of binaries that dynamically check for protocol conformances on conditionally-available
tests. This was fixed in the top-of-tree Swift runtime by https://github.com/apple/swift/pull/29887;
however, that doesn't do much good for running binaries on older OSes that don't have that fix.
In order for binaries built with a newer Swift compiler to run successfully on older OSes,
introduce a compatibility hook that replaces the conformance cache implementation in the original
OS runtime with a version based on the current implementation that has the fix for the protocol
conformance bug. Fixes rdar://problem/59460603
The ConformanceCandidate constructor would eagerly instantiate metadata for
all non-generic types in the conformance cache. This was not the intention
of the code though, because it can compare nominal type descriptors --
which are emitted statically -- for those types that have them, namely
everything except for foreign and Objective-C classes.
Change the order of two calls so that the lazy path has a chance to run.
This fixes a crash when type metadata uses weakly-linked symbols
which are not available, which can come up in backward deployment
scenarios.
Fixes <rdar://problem/59460603>.
It is expected that under enable-private-import internal/private symbols
become public. So that symbol-diffing would fail. Disable symbol diffing
under that test mode.
rdar://51304243
Windows uses `\` for the path separator while other targets use `/`
Use the correct seprator for calculating the basename of the executable
to enable the test on Windows.
PE/COFF does not support weak linking semantics. Disable the tests
until we can emulate the required behaviour. This will allow us to
enable running the validation test suite on Windows in the mean time.
The resilience test helper builds up invocations of the tooling. In
order to do this, we need to know what host we are building for. Plumb
the value for `-triple` from the test harness into the utility. This
will be used subsequently to enable additional testing for Windows.
We have to set the SILFunction's 'weakLinked' flag in the defining
module too, so that it can be serialized. Otherwise when we
deserialize it we are not weak linking calls to the function.
If the conforming type is generic, we have to treat the conformance as
resilient if it is defined outside of the current module.
This is because it can resiliently change from being non-dependent
to dependent.
The naming convention is different on Windows than on Unix-like
environments. In order to follow the convention we need to substitute
the prefix and the suffix. Take the opportunity to rename the
`target-dylib-extension` to the CMake-like variable
`target-shared-library-suffix` and introduce
`target-shared-library-prefix`. This helps linking the test suite
binaries on Windows.
Basically the pattern to optimize is:
inject_enum_addr %stackloc, #SomeCase
switch_enum_addr %stackloc ...
This works even if the enum is resilient and the case does not have a payload. As long as we don't have opaque values in SIL we need this peephole to optimize the pattern.
This change fixes the code generation for Float.rounded().
rdar://problem/46353885
@_fixed_layout classes have resilient vtables now, so we can add and
re-order methods.
Removing overrides is not legal though because they are subject to
devirtualization.
- We don't want to support changing a root class of a class, so don't
pretend that works. Some of these tests got removed recently in
d8104e7e43 but one still remained.
- For the tests that insert a non-root superclass in the inheritance
hierarchy, also test calling a method of the derived class. This
works now that we no longer hardcode vtable offsets and instead use
dispatch thunks.