Commit Graph

143 Commits

Author SHA1 Message Date
Kavon Farvardin b7d57f3bcd Reparenting: use resilient indexing to access base witness table
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
2026-04-20 17:37:36 -07:00
Kavon Farvardin 9e4ecdc128 Reparenting: disallow overriding by inheritees
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
2026-03-06 15:13:56 -08:00
Evan Wilde 6db7c6ced8 Merge pull request #86989 from etcwilde/ewilde/llvm-nm-resilience
Testing: Resilience testing with `llvm-nm`
2026-02-09 09:19:59 -08:00
Evan Wilde 75433fd6eb Disable coro-accessor test on Linux
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.
2026-02-06 16:52:59 -08:00
Evan Wilde 0b2f23c929 Testing: Resilience testing llvm-nm
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.
2026-02-06 16:50:50 -08:00
Kavon Farvardin 6a915549eb Reparenting: allow implied conditional conformances
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.
2026-02-06 16:20:56 -08:00
Kavon Farvardin 6dda8b98d9 Reparenting: require statement of inheritance
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.
2026-02-06 13:23:22 -08:00
Kavon Farvardin 006a0a494a Reparenting: require an extension
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.
2026-02-03 16:40:21 -08:00
Kavon Farvardin eb7fe3c8a3 Reparenting: initial functionality 2026-02-03 16:39:19 -08:00
Arnold Schwaighofer d614ef9acc Fix verify-swift-feature-testing.test-sh -- the second attempt 2026-01-26 06:50:32 -08:00
Arnold Schwaighofer e6c4d85c97 Fix/disable test on certain platforms 2026-01-24 16:23:49 -08:00
Arnold Schwaighofer 83b3bfe19b [CoroutineAccessors] Add a before/after library evolution execution test for _read/modify -> yielding borrow/mutate 2026-01-23 13:44:03 -08:00
Anthony Latsis 3fcadf6c15 Gardening: Migrate test suite to GH issues: validation-test/Evolution 2022-09-19 22:34:06 +03:00
Joe Groff 53e8e7b1d8 SILGen: Don't reference external property descriptors for @_alwaysEmitIntoClient properties.
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.
2022-06-01 16:54:38 -07:00
Josh Soref 0f78f006bb Spelling validation test (#58561) 2022-05-27 22:07:10 -07:00
Joe Groff ca48939816 Compatibility51: Backport the 5.2 implementation of the conformance cache.
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
2020-04-24 10:52:29 -07:00
Slava Pestov d37cf8e47a Disable test_backward_deploy_conformance completely on Swift-in-the-OS bots
Fixes <rdar://problem/59670363>.
2020-02-21 13:09:05 -05:00
Slava Pestov 00ed9e4885 Disable test_backward_deploy_conformance.swift on Swift-in-the-OS bots
We need a backward compatibility shim before this can work.

Fixes <rdar://problem/59631880>.
2020-02-20 13:02:12 -05:00
Slava Pestov 1ca2b61f7a Runtime: Less eager instantiation of type metadata in the conformance cache
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>.
2020-02-17 16:24:42 -05:00
Karoy Lorentey b90e2ef776 [test] Denineninenineninify behavioral tests added for 5.1 2019-08-27 15:44:04 -07:00
Arnold Schwaighofer a22b4f79ec Merge pull request #25406 from aschwaighofer/enable_remaining_implicit_dynamic
Remove the remaining swift_test_mode_optimize_none_with_implicit_dynamic
2019-06-13 08:17:13 -07:00
Arnold Schwaighofer 127b2ab939 Remove the remaining swift_test_mode_optimize_none_with_implicit_dynamic
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
2019-06-12 15:54:49 -07:00
Saleem Abdulrasool 9e901eb0f8 test: fix the path separator for Evolution.test_rth
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.
2019-06-12 13:48:08 -07:00
Slava Pestov 6798eea160 Evolution: Some of these tests pass with swift_test_mode_optimize_none_with_implicit_dynamic
The remaining failures still warrant investigation.
2019-06-11 00:54:32 -07:00
Saleem Abdulrasool 01cf8a8dfc tests: disable backward deployment tests 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.
2019-06-10 17:05:56 -07:00
Saleem Abdulrasool 1e630a5969 test: plumb --triple to the resilience test helper
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.
2019-06-02 17:55:34 -07:00
Ben Cohen e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Arnold Schwaighofer 11c665715c Opaque types require the next Swift runtime
rdar://50503909
2019-05-08 09:50:53 -07:00
Arnold Schwaighofer a793dfb451 Respect resilience when specializing opaque type archetypes 2019-05-01 09:31:07 -07:00
Arnold Schwaighofer e113ef8c93 Add a mode to test implicit dynamic with private imports 2019-03-20 14:34:01 -07:00
Slava Pestov b9bda84e28 SIL: Fix calls of @_weakLinked functions from serialized SIL
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.
2019-02-22 21:10:18 -05:00
Slava Pestov 71ab1bbe77 IRGen: Fix isResilientConformance() check
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.
2019-02-20 20:00:46 -05:00
Arnold Schwaighofer c711181f83 Merge pull request #21256 from aschwaighofer/irgen_conditionally_test_weak_enum_cases
IRGen: Conditionally test weakly linked enum cases
2018-12-13 08:06:47 -08:00
swift-ci f453092465 Merge pull request #21152 from compnerd/library-prefix-suffix 2018-12-12 12:45:21 -08:00
Arnold Schwaighofer 5ae00ee2a2 IRGen: Conditionally test weakly linked enum cases
rdar://46438568
2018-12-12 11:18:12 -08:00
Arnold Schwaighofer 0c01906218 Address review feedback 2018-12-12 08:22:09 -08:00
Saleem Abdulrasool b212229db1 test: add and use prefix substitutions for libraries
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.
2018-12-11 15:56:06 -08:00
Arnold Schwaighofer 2f34bdcbbc IRGen: Don't hoist metadata for weakly linked types
rdar://46438608
2018-12-11 13:15:33 -08:00
Erik Eckstein 5c17f0f6f8 SILCombine: peephole to propagate resilient enum cases
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
2018-12-10 16:14:15 -08:00
Slava Pestov a6f4c8a60d Evolution: Code review feedback for backward deployment tests 2018-12-04 15:13:44 -05:00
Slava Pestov f5b448f75a Evolution: Add backward deployment tests 2018-12-03 20:36:03 -05:00
Slava Pestov 57c4dc3831 Evolution: Stylistic fixes for tests 2018-12-03 20:36:03 -05:00
Slava Pestov a5abb9d7ed Evolution: Add some tests for @_fixed_layout classes
@_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.
2018-11-29 23:20:02 -05:00
Slava Pestov 9af20c71f0 Evolution: Clean up superclass insertion tests a bit
- 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.
2018-11-29 23:20:02 -05:00
Slava Pestov 547746719a Evolution: Test adding a new convenience init to an open class 2018-11-28 12:39:04 -05:00
Slava Pestov e24c4c3f63 Evolution: Test that adding willSet/didSet to a stored property works 2018-11-28 12:39:04 -05:00
Slava Pestov 6028912131 Evolution: Test that adding or removing weak/unowned is a resilient change 2018-11-28 12:39:04 -05:00
Slava Pestov 890bf2eeed Evolution: Test adding a class deinit 2018-11-28 12:39:04 -05:00
Slava Pestov 16fccd6a51 Evolution: Test moving methods between class/struct and extension 2018-11-28 12:39:04 -05:00
Slava Pestov 0781ab85b6 Evolution: Add test changing a lazy property a computed property with a mutating getter 2018-11-28 12:39:04 -05:00