Commit Graph

15 Commits

Author SHA1 Message Date
Meghana Gupta
e8abd59da5 Update tests 2024-11-18 18:09:19 -08:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Kavon Farvardin
30983530b6 NCGenerics: introduce SuppressedAssociatedTypes
The model for associated types hasn't been fully worked-out for
noncopyable generics, but there is some support already that is being
used by the stdlib for an internal-only (and rather cursed) protocol
`_Pointer` to support `UnsafePointer`, etc.

This patch gates the existing experimental support for associated types
behind a feature flag. This flag doesn't emit feature-guards in
interfaces, since support for it is tied closely to NoncopyableGenerics
and has been there from its early days.
2024-04-02 16:53:36 -07:00
Doug Gregor
757ebe2979 Future-proof the mangling of invertible protocols
Invertible protocols are currently always mangled with `Ri`, followed by
a single letter for each invertible protocol (e.g., `c` and `e` for
`Copyable` and `Escapable`, respectively), followed by the generic
parameter index. However, this requires that we extend the mangling
for any future invertible protocols, which mean they won't be
backward compatible.

Replace this mangling with one that mangles the bit # for the
invertible protocol, e.g., `Ri_` (followed by the generic parameter
index) is bit 0, which is `Copyable`. `Ri0_` (then generic parameter
index) is bit 1, which is `Escapable`. This allows us to round-trip
through mangled names for any invertible protocol, without any
knowledge of what the invertible protocol is, providing forward
compatibility. The same forward compatibility is present in all
metadata and the runtime, allowing us to add more invertible
protocols in the future without updating any of them, and also
allowing backward compatibility.

Only the demangling to human-readable strings maps the bit numbers
back to their names, and there's a fallback printing with just the bit
number when appropriate.

Also generalize the mangling a bit to allow for mangling of invertible
requirements on associated types, e.g., `S.Sequence: ~Copyable`. This
is currently unsupported by the compiler or runtime, but that may
change, and it was easy enough to finish off the mangling work for it.
2024-03-28 21:26:13 -07:00
Doug Gregor
994e342c98 [Demangle-to-AST] Match invertible-generics extensions with no signature
Introduce a predicate that determines when a given extension corresponds
to what one would get by existing the nominal type without spelling out
any constraints. This differs from the notion of a "constrained
extension" when the nominal type suppresses conformances on any of its
generic parameters, e.g.,

    struct X<T: ~Copyable> { ... }

    // doesn't spell out any constraints, but is constrained because it
    // implicitly adds T: ~Copyable.
    extension X { ... }

    // does spell out constraints, but is not constrained because the
    // generic signature matches that of X.
    extension X where T: ~Copyable { }

Use this predicate when demangling a name to metadata, because name
mangling for extensions suppresses the generic signature for cases
where one "doesn't spell out any constraints."
2024-03-27 17:07:41 -07:00
Doug Gregor
bd8ab1641d [Demangle-to-AST type] Make sure we can find the original nominal type in its own module
With noncopyable generics, we can end up using an extension mangling to refer to the
original nominal type, even in its own module. Make sure we resolve that to the
original nominal type declaration, rather than hunting for an extension that
might not be there.
2024-03-23 11:34:47 -07:00
Doug Gregor
942eb62743 [Demangle-to-type] Properly match extensions of conditionally-copyable types
We weren't dealing with the case where an extension in a different module
from the type uses an extension mangling with no generic signature.

Fixes rdar://125015930.
2024-03-19 12:56:40 -07:00
Doug Gregor
854d0875ba Enable @_preInverseGenerics to suppress mangled names in more places
Fixes rdar://124644596.
2024-03-14 23:07:27 -07:00
Doug Gregor
a2ae2149e8 Demangle inverse requirements when building AST types
Extend TypeDecoder with support for inverse requirements, passing them
along to the type builder. Then implement support for inverse
requirements within the AST demangler, which addresses the round-trip
demangling failures we've been seeing.

The runtime and remote inspection facilities still need metadata to
deal with inverse requirements.

Fixes rdar://124564447.
2024-03-14 14:01:53 -07:00
Doug Gregor
77512f8ffe [Noncopyable] Mangle enum elements as "always in the primary definition"
For entities that must be part of the primary definition of a type,
mangle without inverses on the generic parameters of the enclosing
type. This ensures that we can adopt noncopyable on the generic
parameters without breaking the mangling of the fundamental entities
that describe the layout of the type.

Do this for enum elements first, so we don't break the mangling of
`Optional`. There will be other cases to consider as well.
2024-03-13 16:39:32 -07:00
Doug Gregor
1cd7a56ea6 [Noncopyable] Many protocol members without the inverse requirements of the protocol itself
This eliminates the ABI impact of making `Self` or associated types in
a protocol `~Copyable`.
2024-03-12 17:06:12 -07:00
Doug Gregor
1d48c2769a Generalize test for Linux/Windows more 2024-03-11 14:15:43 -07:00
Doug Gregor
b96ffb7353 Generalize test for Linux 2024-03-08 16:51:03 -08:00
Doug Gregor
e1ee19ac5e [Noncopyable generics] Suppress inverse conformance mangling for more symbols
Don't mangle inverse conformances for symbols related to dispatch thunks,
protocol members, and other entities that are inexorably tied to the
primary definition of the type and must have stable names.

Extend the conditional suppression of inverse conformance mangling to
property descriptors and more conformance-related symbols.
2024-03-07 10:01:20 -08:00