Commit Graph

39 Commits

Author SHA1 Message Date
Allan Shortlidge
b39637159c AST: Promote RethrowsProtocol feature to baseline. 2024-07-09 14:28:29 -07:00
Kavon Farvardin
f0f91eedc9 NCGenerics: avoid feature-guarding in some cases
With the generalization of Optional to support noncopyable types, our
feature-guarding in swiftinterface files would double-print functions
that simply refer to the Optional type.

Since NoncopyableGenerics is a suppressible feature, by default
a second version of Optional and UnsafePointer are emitted into
swiftinterface files, where the ~Copyable generalization is stripped
away.

We can rely on that to avoid double-printing the function, if the types
substituted for the generic parameters are all Copyable.

We need a bit more checking for when
`@_disallowFeatureSuppression(NoncopyableGenerics)` is used, since this
trick relies on there always being a definition of the type we refer to,
whether the feature is enabled or not.

resolves rdar://127389991
2024-05-08 15:48:54 -07:00
Karoy Lorentey
bd39c35026 [test] Un-xfail tests that are passing now that NoncopyableGenerics is a suppressible feature 2024-03-18 12:32:33 -07:00
Allan Shortlidge
ba9b3023e0 AST: Make $UnavailableFromAsync and $NoAsyncAvailability baseline features.
They have been available since at least Swift 5.8.
2024-03-02 23:15:41 -08:00
Allan Shortlidge
d5e3e9418d AST: Make $UnsafeInheritExecutor a baseline feature.
It has been available since at least Swift 5.8.
2024-03-02 23:15:41 -08:00
Allan Shortlidge
bb416e12cf ModuleInterface: Use --implicit-check-not in features.swift test. 2024-03-02 23:15:41 -08:00
Doug Gregor
63c8fe3e4d Clean up formatting in test cases 2024-02-14 21:53:54 -08:00
Doug Gregor
bae1026b77 Stop emitting conditions for Swift 5.5-era features into textual interfaces
The "#if compiler(>=5.3) && $AsyncAwait" checks were necessary for
staging in concurrency in Swift 5.5. At this point, it's safe to assume
that any compiler that tries to read a generated Swift interface file will
support concurrency, so we can stop emitting these guards.
2024-02-14 21:51:55 -08:00
Allan Shortlidge
670f395b90 Frontend: Enable $GlobalActors feature by default.
Global actors have been an accepted language feature for a couple of compiler releases now, but the feature definition was associated with the `--enable-experimental-concurrency` flag. This caused some `.swiftinterface`s containing global actor declarations to be unparsable because the logic for surrounding declarations with the `$GlobalActors` feature guard was incomplete (for example, classes with a global actor attribute were not guarded even though the declarations of global actor types were).

Rather than trying to fix the logic of `usesFeatureGlobalActors()`, enable it by default.

Adds a test that demonstrates that modules defining and using public global actors produce module interfaces that can be parsed successfully.

Resolves rdar://100150703
2022-10-03 14:49:11 -07:00
Allan Shortlidge
e0e748c35a ModuleInterface: Print existential any in swiftinterfaces since any is required for protocols with associated types in 5.7.
Resolves rdar://92976269
2022-05-09 14:10:07 -07:00
Allan Shortlidge
747f286b8d ModuleInterface: Adopt new swiftinterface verification lit substitutions pervasively in tests where they can be adopted by simply updating or adding a few RUN: lines. 2022-04-15 20:13:00 -07:00
Allan Shortlidge
f27005b8d0 ModuleInterface: When printing synthesized extensions, we need to be sure to guard them with required features if applicable. Not doing so can result in broken interfaces that do not typecheck because, for instance, a conformance can refer to a nominal type that is only declared when certain features are enabled.
Also, fix a typo where `#elsif` was printed into interfaces instead of `#elseif`.

Resolves rdar://91509673
2022-04-12 17:53:59 -07:00
Evan Wilde
aa51bdf17a Add noasync availability kind to available attr
This patch adds the `noasync` availability kind to `@available`. The
spelling is `@available(*, noasync)`.
2022-03-22 15:12:51 -07:00
Evan Wilde
822097353b Check unavailable from async in interface file
We need to check the feature availability of _unavailableFromAsync
before it gets picked up in the swift interface file. This updates the
compiler to provide the necessary wrappings for that check.
2022-03-04 15:16:03 -08:00
John McCall
54c38cbb71 Fix and generalize the printing of suppressible features,
and make `@_unsafeInheritExecutor` a suppressible feature.

Some language features are required in order to parse a
declaration correctly, but some can safely be ignored.
For the latter, we'd like the module interface to simply
contain the declaration twice, once with the feature and
once without.  Some basic support for that was already
added for the SpecializeAttributeWithAvailability feature,
but it didn't interact correctly with required features
that might be checked in the same `#if` clause (it simply
introduced an `#else`), and it wasn't really set up to
allow multiple features to be handled this way.  There
were also a few other places that weren't updated to
handle this, presumably because they never coincided
with a `@_specialize` attribute.

Introduce the concept of a suppressible feature, which
is anything that the ASTPrinter can modify the current
PrintOptions in order to suppress.  Restructure the
printing of compatibility checks so that we can print
the body multiple times with different settings.
Print required feature checks in an outer `#if...#endif`,
then perform a separate `#if...#else...#endif` within
if we have suppressible features.  If there are multiple
suppressible features, check for the most recent first,
on the assumption that it will imply the rest; then
perform subsequent checks with an `#elsif` clause.

This should be a far more solid foundation on which to
build compatibility checks in the future.

`@_unsafeInheritExecutor` needs to be suppressible
because it's been added to some rather important
existing APIs.  Simply suppressing the entire decl will
effectively block old tools from using a new SDK to
build many existing projects (if they've adopted
`async`).  Dropping the attribute changes the semantics
of these functions, but only if the compiler features
the SE-0338 scheduling change; this is a very narrow
window of main-branch development builds of the tools,
none of which were officially released.
2022-02-16 16:58:56 -05:00
Arnold Schwaighofer
0965a63eb8 Test case 2021-10-30 06:16:30 -07:00
Doug Gregor
eeeea49764 Remove -enable-experimental-concurrency almost everywhere. 2021-07-26 21:24:43 -07:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07:00
Doug Gregor
06bbc70b3e Module printing and serialization support for @unchecked Sendable 2021-07-11 12:29:54 -07:00
Varun Gandhi
02afb9d49b [ModuleInterface] Print full type if ambiguous for extensions.
The patch introduces a new setting instead of changing existing settings
because the generated interfaces in the IDE have slightly different
requirements; the extended type there is unconditionally not printed
qualified (even if it is ambiguous). This is likely because the
ambiguity heuristic is very weak; it doesn't even do name lookup.
Simplifying that logic would be nice, but then we'd need to update
a bunch of IDE/print* tests and end up with more more visual clutter
in the IDE.

Introducing the new setting means we can change the behavior for
swiftinterface files without affecting the behavior for IDE interfaces.

Fixes rdar://79093752.
2021-06-11 20:04:43 -07:00
John McCall
186c53000d Introduce basic support for custom executors.
- Introduce an UnownedSerialExecutor type into the concurrency library.
- Create a SerialExecutor protocol which allows an executor type to
  change how it executes jobs.
- Add an unownedExecutor requirement to the Actor protocol.
- Change the ABI for ExecutorRef so that it stores a SerialExecutor
  witness table pointer in the implementation field.  This effectively
  makes ExecutorRef an `unowned(unsafe) SerialExecutor`, except that
  default actors are represented without a witness table pointer (just
  a bit-pattern).
- Synthesize the unownedExecutor method for default actors (i.e. actors
  that don't provide an unownedExecutor property).
- Make synthesized unownedExecutor properties `final`, and give them
  a semantics attribute specifying that they're for default actors.
- Split `Builtin.buildSerialExecutorRef` into a few more precise
  builtins.  We're not using the main-actor one yet, though.

Pitch thread:
  https://forums.swift.org/t/support-custom-executors-in-swift-concurrency/44425
2021-04-30 03:11:56 -04:00
Doug Gregor
cdd6ad8bfd Introduce a feature for @_inheritActorContext
Add a feature for this new attribute, and make sure we use the feature
guard for functions that use it, e.g., the new `async`.

Finishes rdar://76927008.
2021-04-22 15:49:48 -07:00
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00
Doug Gregor
9579390024 [SE-0304] Rename ConcurrentValue to Sendable 2021-03-18 22:48:20 -07:00
Doug Gregor
c18ef1af94 Properly collect all enclosing features. 2021-03-12 11:23:27 -08:00
Doug Gregor
7015543c9c [Module interfaces] More aggressively #if-out declarations.
Extend the checks for marker protocols and rethrows protocols to ensure
that we #if out more code that relies on them in module interface
generation. This makes the _Concurrency module parseable by much older
compilers.

Fixes rdar://75291705.
2021-03-11 22:03:29 -08:00
Doug Gregor
2b9fa92914 [AST Printing] Consider the storage decl as the "enclosing" decl of an acccessor
Fixes spurious #if's when printing for backward compatibility, rdar://75074036
2021-03-04 21:47:17 -08:00
Doug Gregor
b5e4b085aa Infer ConcurrentValue conformances for structs and enums.
When a struct or enum has only ConcurrentValue-conforming instance
data, infer conformance to ConcurrentValue.
2021-03-02 00:23:33 -08:00
Doug Gregor
e7d7585503 Add a feature for global actors & module interface support 2021-02-22 20:46:58 -08:00
Doug Gregor
f21c60928c Add feature for rethrows protocols and use it in module interface generation 2021-02-22 16:18:47 -08:00
Doug Gregor
2fd1912f5a Simplify printing of marker protocols in Swift interfaces
Thanks to a great idea from Slava, simplify the printing of marker
protocols in Swift interfaces while maintaining backward compatibility.
For compilers that cannot handle marker protocols, print a typealias
to `Any` instead, which is a good stand-in for just about everything.
2021-02-18 22:58:19 -08:00
Doug Gregor
e8375e13ee Define a feature for @concurrent functions. 2021-02-12 16:36:12 -08:00
Doug Gregor
43df1d8363 [Concurrency] Don't spuriously record protocols inherited by Actor. 2021-02-10 15:52:03 -08:00
swift-ci
bcfafc1b07 Merge pull request #35854 from davezarzycki/pr35854 2021-02-09 13:07:51 -08:00
David Zarzycki
5a17429b25 [Testing] Add missing REQUIRES: concurrency 2021-02-09 13:26:44 -05:00
Doug Gregor
b1aa56dbd1 Clean up test comment and mark as REQUIRES: concurrency 2021-02-09 09:28:17 -08:00
Doug Gregor
643ce71a09 Peer into the types of declarations to find async/actors/etc. 2021-02-08 22:50:48 -08:00
Doug Gregor
627e4f03a3 Properly print protocols that inherit marker protocols under $MarkerProtocol 2021-02-08 22:37:13 -08:00
Doug Gregor
aa139a101c [Module interface] Use features in module interface generation.
When generating a module interface, emit `#if` around any declarations
that are tied to specific, named language features. This allows module
interfaces to be processed by older Swift compilers that do not
support these newer features, such as async/await or actors.

The amount of effort required to correctly handle a new kind of
feature varies somewhat drastically based on the feature itself. The
"simple" case is where a particular declaration can only exist if a
feature is available. For example, and `async` declaration is fairly
easy to handle; a `@_marker` protocol's conformances are not.

Fixes rdar://73326633.
2021-02-08 16:01:39 -08:00