Commit Graph

130 Commits

Author SHA1 Message Date
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
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.
2025-11-07 22:00:40 -08:00
Allan Shortlidge
92227ad1cf AST: Introduce the Swift, anyAppleOS, and DriverKit platform kinds.
This change just stages in a few new platform kinds, without fully adding
support for them yet.

- The `Swift` platform represents availability of the Swift runtime across all
  platforms that support an ABI stable Swift runtime (see the pitch at
  https://forums.swift.org/t/pitch-swift-runtime-availability/82742).
- The `anyAppleOS` platform is an experimental platform that represents all of
  Apple's operating systems. This is intended to simplify writing availability
  for Apple's platforms by taking advantage of the new unified OS versioning
  system announced at WWDC 2025.
- The `DriverKit` platform corresponds to Apple DriverKit which is already
  supported by LLVM.
2025-10-27 19:15:04 -07:00
Guillaume Lessard
dc759fded8 [test] add Android to availability attribute test (#85057)
Following up to https://github.com/swiftlang/swift/pull/84574
2025-10-23 19:31:31 +05:30
michael-yuji
9a948a9c3b Merge branch 'main' into mchiu/freebsd 2025-05-21 16:29:16 -07:00
Becca Royal-Gordon
01431b87b2 Make @abi non-experimental
This includes changing the feature name so that compilers with the experimental feature don’t accidentally pick up content that only works in the final version.

Resolves rdar://150065196.
2025-05-05 13:50:51 -07:00
Pavel Yaskevich
0ad7d8b590 [AST] Prevent use of @extensible without ExtensibleAttribute feature 2025-04-24 12:10:53 -07:00
Alex Hoppen
f858e713ce Merge pull request #80804 from DataCorrupted/IDE
[IDE] Fix a test in IDE
2025-04-17 14:31:17 -07:00
Peter Rong
a93b8805b6 [IDE] Also add missing tests from #80668 2025-04-15 15:16:31 -07:00
Peter Rong
d10c305d33 [IDE] Fix a test in IDE
There was an error in IDE: It's not failing because it diesabled that test.

Signed-off-by: Peter Rong <PeterRong@meta.com>
2025-04-14 15:08:11 -07:00
Pavel Yaskevich
f1b3c7b604 [AST] Remove ExecutionAttribute experimental feature
SE-0461 has been accepted and `@concurrent` and `nonisolated(nonsending)`
can be make generally available now.
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
a0ae93d3a8 [AST/Sema] Add @extensible attribute on enum declarations
This attribute controls whether cross-module access to the declaration
needs `@unknown default:` because it's allowed to gain new cases even
if the module is non-resilient.
2025-04-03 16:30:19 -07:00
Michael Chiu
03463ea0cc fix test 2025-03-14 02:15:15 -04:00
Pavel Yaskevich
dd1be8f6d4 [Frontend] Hide @execution attribute behind an experimental feature ExecutionAttribute
Since the proposal has not been approved yet we cannot expose
`@execution` attribute.
2025-02-20 00:05:03 -08:00
Pavel Yaskevich
01e3bd0636 [AST] Disconnect @execution(...) attribute from the feature flag
The attribute has to be available without feature flag on so that
it could be adopted preemptively, before the behavior change.
2025-02-05 00:16:57 -08:00
Meghana Gupta
c5f2c5f0e2 [NFC] Update IDE test for @lifetime 2024-09-10 11:37:50 -07:00
Alexander Cyon
a80b8ae06f [test/IDE] Fix typos 2024-08-08 19:35:00 +02:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Yuta Saito
79b3d2d626 Add underscore prefix to extern attribute
It's already guarded by a feature flag, but it would be nice to signal
users that it's not stable yet by adding an underscore prefix.
2023-11-07 02:01:02 +00:00
Yuta Saito
69479933df [c-interop] Rename @_extern to @extern
Now the feature is gated by experimental feature flag.
It's not shipped in any language release, so this rename should be fine.
2023-10-20 17:37:43 +00:00
Rintaro Ishizaki
fcaae5cc9b [CodeCompletion] Add fake type annotation to custom attributes
Macros and custom attribute types (i.e. `@resultBuilder`,
`@propertyWrapper`, and `@globalActor`) now have fake type
annotations. This would be useful to recognize which candidates are
actually usable in code completions after `@`.

rdar://109062582
2023-09-18 14:07:01 -07:00
Pavel Yaskevich
4bd60aeb4e [Tests] NFC: Remove/adjust runtime metadata related test cases 2023-08-15 12:17:31 -07:00
Pavel Yaskevich
fe17491982 [AST] InitAccessors: Switch from init accessor effects (initializes/accesses) to @storageRestrictions 2023-07-07 10:00:36 -07:00
Alex Hoppen
d5e97501fa [CodeCompletion] Suggest freestanding after @
rdar://108163121
2023-04-25 18:06:47 -07:00
Ben Barham
31dee1ce1c [Completion] Only provide macro completions when they are valid
Only return macros that are valid in their current position, ie. an
attached macro is not valid on a nominal.

Also return freestanding expression macros in code block item position
and handle the new freestanding code item macros.

Resolves rdar://105563583.
2023-04-07 18:43:06 -07:00
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Doug Gregor
7177a16c4c [Code completion] Provide attached macro names after @ 2023-03-04 21:42:36 -08:00
Alex Hoppen
61e8882568 [IDE] Compute type relations for attributes for generic property wrapper types
The existing logic to check whether a type is a valid property wrapper only worked for nominal types, not generic types. Also consider generic types.
2023-02-17 19:32:39 +01:00
Pavel Yaskevich
e2b22d9f62 [AST/Sema] Remove TypeWrapper feature functionality 2023-02-08 00:16:00 -08:00
Allan Shortlidge
022abe4d3b NFC: Update tests to use accepted spelling for @backDeployed. 2023-02-01 22:04:33 -08:00
Richard Wei
dbbf6aa4f1 Merge branch 'main' into freestanding-macro-attr-cleanup 2023-01-26 18:09:45 +08:00
Doug Gregor
8d92f110c3 Update IDE test for removal of @expression and @declaration 2023-01-25 17:07:38 -08:00
Pavel Yaskevich
477a54a145 [AST] RuntimeMetadata: Allow using enums as custom runtime metadata types 2023-01-24 14:16:36 -08:00
Doug Gregor
de16b47875 [Macros] Introduce the @attached attribute for declaring attached macros.
Describe attached macros with the `@attached` attribute, providing the
macro role and affected names as arguments to the macro. The form of
this macro will remain the same as it gains other kinds of attached
macro roles beyond "accessor".

Remove the "accessors" role from `@declaration`, which will be going
away.
2023-01-13 22:47:59 -08:00
Richard Wei
f17b7c48bf [Macros] Freestanding declaration macros
Add support for freestanding declaration macros.

- Parse `@declaration` attribute.
- Type check and expand `MacroExpansionDecl`.

Known issues:
- Generic macros are not yet handled.
- Expansion does not work when the parent decl context is `BraceStmt`. Need to parse freestanding declaration macro expansions in `BraceStmt` as `MacroExpansionDecl`, and add expanded decls to name lookup.
2023-01-10 19:09:11 -08:00
Doug Gregor
3e2bafc2f2 [Macro] Add the expression attribute for macro declarations 2022-12-22 09:10:01 -08:00
Pavel Yaskevich
59163524a5 [Sema] Add skeleton implementation of @runtimeMetadata attribute
Use of the attribute is gated on `RuntimeDiscoverableAttrs` flag.
2022-11-15 17:33:13 -08:00
Pavel Yaskevich
116dea2f6d [AST/TypeChecker] TypeWrappers: Add @typeWrapperIgnored attribute
`@typeWrapperIgnored` attribute could be used on stored properties
of a type wrapped type to exclude them from type wrapper transform.
2022-09-09 23:52:35 -07:00
Pavel Yaskevich
38765fbd9a [AST] Add a new @typeWrapper attribute 2022-08-26 12:25:22 -07:00
Alex Hoppen
df605d479d [CodeCompletion] Mark types that can’t be used as attributes as having an invalid type relation when used after '@'
When completing after `@`, record what kind of attributes are applicable here (property wrapper, result builder, global actor), mark types that are marked as property wrapper etc. as having a 'Convertible' type relation and mark all other types as having an invalid type relation.

rdar://78239501
2022-05-06 20:09:12 +02:00
Doug Gregor
7149702d12 Rename @_predatesConcurrency to @preconcurrency.
Introduce the `@preconcurrency` attribute name for `@_predatesConcurrency`,
which has been the favored name in the pitch thread so far. Retain the
old name for now to help smooth migration.
2022-01-26 08:39:01 -08:00
Erik Eckstein
5fd941eb67 Add the @exclusivity attribute.
The `@exclusivity(unchecked)` attribute can be used on variables to selectively disable exclusivity checking.
For completeness, also the `@exclusivity(checked)` variant is supported: it turns on exclusivity checking for specific variables if exclusivity enforcement is disabled by the command line option.

This new attribute is a missing implementation part of SE-0176 (https://github.com/apple/swift-evolution/blob/main/proposals/0176-enforce-exclusive-access-to-memory.md).

rdar://31121356
2022-01-25 08:06:45 +01:00
Evan Wilde
a84650bb60 Make _unavailableFromAsync user inaccessible
Just making this user inaccessible until I go through the full proposal
pipeline.
2021-12-03 14:53:55 -08:00
Evan Wilde
694fad4aef Adding unavailableFromAsync tests
This patch adds a bunch of tests to verify the behaviour of the
@_unavailableFromAsync attribute.

The attribute is only allowed on functions, so we verify that an error
is emitted when it is applied to structs, extensions, classes, and
actors. The attribute may be applied to constructors to disallow
construction in an async context, but cannot be applied to destructors
since a destructor must be callable from anywhere. Additionally, the
attribute cannot be applied to asynchronous functions since an async
function _must_ be called from an async context.

Specific checks include
 - Errors are emitted in an async context (global function, e.g.)
 - Errors are emitted when the async context is nested in a sync context
 - Errors are not emitted from a sync context nested in an async context

This patch also includes verification that the attribute is propagated
across module boundaries and is be imported from ObjC functions.

Lastly, this patch adds the IDE completion testing to verify that the
attribute is considered.
2021-11-30 14:20:21 -08:00
Doug Gregor
f5dc1a1b48 [SE-0316] Global actors
Enable global actors by default. The proposal has been accepted and is
implemented.
2021-06-30 14:40:44 -07:00
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00
Doug Gregor
f56ba59605 Add 'nonisolated' modifier as the preferred spelling for @actorIndependent 2021-03-07 10:57:35 -08:00
Slava Pestov
6c69d17e0c Parse: Implement parsing for 'reasync' attribute
Part of <rdar://problem/71098795>.
2021-02-15 22:18:54 -05:00
Doug Gregor
184b150015 Allow the @concurrent function attribute without the concurrency flag 2021-02-12 16:36:12 -08:00
Philippe Hausler
6e05240426 AsyncSequence and protocol conformance rethrows (#35224)
* Initial draft of async sequences

* Adjust AsyncSequence associated type requirements

* Add a draft implementation of AsyncSequence and associated functionality

* Correct merge damage and rename from GeneratorProtocol to AsyncIteratorProtocol

* Add AsyncSequence types to the cmake lists

* Add cancellation support

* [DRAFT] Implementation of protocol conformance rethrowing

* Account for ASTVerifier passes to ensure throwing and by conformance rethrowing verifies appropriately

* Remove commented out code

* OtherConstructorDeclRefExpr can also be a source of a rethrowing kind function

* Re-order the checkApply logic to account for existing throwing calculations better

* Extract rethrowing calculation into smaller functions

* Allow for closures and protocol conformances to contribute to throwing

* Add unit tests for conformance based rethrowing

* Restrict rethrowing requirements to only protocols marked with @rethrows

* Correct logic for gating of `@rethrows` and adjust the determinates to be based upon throws and not rethrows spelling

* Attempt to unify the async sequence features together

* Reorder try await to latest syntax

* revert back to the inout diagnosis

* House mutations in local scope

* Revert "House mutations in local scope"

This reverts commit d91f1b25b59fff8e4be107c808895ff3f293b394.

* Adjust for inout diagnostics and fall back to original mutation strategy

* Convert async flag to source locations and add initial try support to for await in syntax

* Fix case typo of MinMax.swift

* Adjust rethrowing tests to account for changes associated with @rethrows

* Allow parsing and diagnostics associated with try applied to for await in syntax

* Correct the code-completion for @rethrows

* Additional corrections for the code-completion for @rethrows this time for the last in the list

* Handle throwing cases of iteration of async sequences

* restore building XCTest

* First wave of feedback fixes

* Rework constraints checking for async sequence for-try-await-in checking

* Allow testing of for-await-in parsing and silgen testing and add unit tests for both

* Remove async sequence operators for now

* Back out cancellation of AsyncIteratorProtocols

* Restructure protocol conformance throws checking and cache results

* remove some stray whitespaces

* Correct some merge damage

* Ensure the throwing determinate for applying for-await-in always has a valid value and adjust the for-await-in silgen test to reflect the cancel changes

* Squelch the python linter for line length
2021-01-25 18:48:50 -08:00
Saleem Abdulrasool
7c968c6ccf AST: support availability on Windows
Enable Windows specific availability annotations in Swift.
2020-11-09 20:03:52 -08:00