Commit Graph

726 Commits

Author SHA1 Message Date
Arnold Schwaighofer
13ff5abdb8 Introduce @specialized attribute
Implements SE-0460 -- the non-underscored version of @specialized.

It allows to specify "internal" (not abi affecting) specializations.

rdar://150033316
2025-05-23 13:12:47 -07:00
Pavel Yaskevich
c0aca5384b [ASTGen] Transform @_inheritActorContext into a custom attribute with an optional modifier 2025-05-14 20:07:59 -07:00
Ben Barham
6667471b3d Merge pull request #81115 from beccadax/abi-let-you-graduate
Finish implementing `@abi` (SE-0476)
2025-05-08 12:52:00 -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
Michael Gottesman
9d59dbed17 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
2025-05-05 13:39:03 -07:00
Pavel Yaskevich
498430afaf [AST/Sema] Add @preEnumExtensibility attribute to downgrade warnings for extensible enums
Just like `@preconcurrency` for concurrency, this attribute is going
to allow exhaustiveness error downgrades for enums that were retroactively
marked as `@extensible`.
2025-05-02 09:07:22 -07:00
Doug Gregor
235242e8b3 [Diagnostics] Use the swift-syntax formatting for invalid source locations, too
The diagnostics formatter from swift-syntax previously only handled
fully-formed diagnostics anchored at a particular syntax node.
Therefore, the compiler would fall back to the existing LLVM-based
diagnostic formatter for diagnostics that had no source location.

Adopt new API in the swift-syntax diagnostics formatter that renders a
diagnostic message without requiring source location information, so
that we consistently use the swift-syntax formatter when it is
selected (which is the default).
2025-04-18 15:36:43 -07:00
Pavel Yaskevich
07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
54b62ae983 [AST/Parse] Implement nonisolated(nonsending) type modifier 2025-04-11 15:59:25 -07:00
Pavel Yaskevich
b1ffa063b6 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-11 15:57:11 -07:00
Pavel Yaskevich
4b8c8e7d72 [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-11 12:08:29 -07:00
Pavel Yaskevich
318c4150f3 [AST/Sema] Support for @concurrent attribute in type context 2025-04-11 12:08:29 -07:00
Pavel Yaskevich
2704ab7337 [AST/ASTGen] Introduce @concurrent attribute to replace @execution(concurrent) spelling 2025-04-11 12:08:29 -07:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
6eaa07a880 Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout
Revert "Add support for inout lifetime dependence"
2025-04-04 09:31:46 -07:00
Pavel Yaskevich
8bf8c24bf9 Merge pull request #80503 from xedin/extensible-attr
[AST/Sema] Add `@extensible` attribute on `enum` declarations
2025-04-04 09:17:56 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Meghana Gupta
50ea777936 Merge pull request #80452 from meg-gupta/lifetimeinout
Add support for inout lifetime dependence
2025-04-04 02:04:53 -07:00
Meghana Gupta
d87a2b2ada Rename ParsedLifetimeDependenceKind::Scope -> ParsedLifetimeDependenceKind::Borrow 2025-04-03 17:22:13 -07:00
Meghana Gupta
cfacd25df4 Add support for @lifetime(&arg) 2025-04-03 17:22:06 -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
Hamish Knight
2e1c37f1ab [ASTScope] Allow try in unfolded sequence to cover following elements
Rather than fixing-up in the parser, adjust the ASTScope logic such
that a `try` element in a SequenceExpr is considered as covering all
elements to the right of it. Cases where this isn't true are invalid,
and will be diagnosed during sequence folding. e.g:

```
0 * try foo() + bar()
_ = try foo() ~~~ bar() // Assuming `~~~` has lower precedence than `=`
```

This ensures we correctly handle `try` in assignment sequences, and
allows ASTGen to get the behavior for free.

rdar://132872235
2025-04-02 12:46:21 +01:00
Ben Barham
18bffd450f Merge pull request #80277 from Azoy/value-generic-feature-syntax-removal
[ASTGen] Remove ValueGeneric mapping
2025-04-01 16:16:52 -07:00
Ben Barham
26259f68cb Merge pull request #80351 from rintaro/astgen-attributes-reorg
[ASTGen] Update for specialized attribute kind removal
2025-03-31 10:36:39 -07:00
Doug Gregor
ed2c7d693b Update for rename of FixIt.Change.textualReplacement -> replaceText 2025-03-28 14:39:14 -07:00
Doug Gregor
74fb36f9bc Translate Fix-Its from the C++ diagnostics into swift-syntax diagnostics
The swift-syntax diagnostic formatter doesn't actually print Fix-Its,
but at least they're available now.
2025-03-28 13:20:57 -07:00
Doug Gregor
ceb1152ce7 Add support for FixIt.Change.textualReplacement 2025-03-28 13:20:47 -07:00
Rintaro Ishizaki
2a21e68184 [ASTGen] Update for specialied attribute kind removal
In `SwiftSyntax`, some cases in `AttributeSyntax.Arguments` enum are
being consolidated to `.argumentList(LabeledExprListSyntax)`
2025-03-27 14:02:55 -07:00
Doug Gregor
1b2fad1e78 Properly recurse when removing "unsafe" from inlinable code
I forgot that I have to manually recurse in the syntactic rewriter. Do so.
Fixes rdar://147877042
2025-03-25 16:27:37 -07:00
Kuba (Brecka) Mracek
1c395e24f6 Merge pull request #79923 from kubamracek/mracek/constinitialized
[Compile Time Values] Add parsing of @constInitialized attribute under CompileTimeValues experimental feature
2025-03-25 13:41:17 -07:00
Alejandro Alonso
70a702c30e Remove ValueGeneric mapping from ASTGen 2025-03-25 10:45:06 -07:00
Jakub Florek
0e6001bc61 Merge pull request #80063 from MAJKFL/swift-lexical-lookup-rfc
Refactor `SwiftLexicalLookup` validation to use updated public API interface
2025-03-25 16:19:13 +01:00
Doug Gregor
708300966d [Diagnostics] Fix recognition of URLs in category file/URL 2025-03-24 10:14:25 -07:00
Kuba Mracek
f402eb623c [Compile Time Values] Add parsing of @constInitialized attribute under CompileTimeValues experimental feature 2025-03-24 09:31:57 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Holly Borla
be670da373 Merge pull request #79980 from hborla/closure-body-macro
[Macros] Implement support for function body macros on closures.
2025-03-21 06:19:36 -07:00
Holly Borla
b005df366a [Macros] Add an overload of findSyntaxNodeInSourceFile that accepts
a predicate.

The new overload is used during macro expansion to find the nearest
syntax node that is either a `DeclSyntax` or a `ClosureExprSyntax`.
This avoids an issue where calling the overload that accepts a
specific type may find an outer, unrelated declaration or closure.
2025-03-20 18:58:47 -07:00
Rintaro Ishizaki
4762985b47 [ASTGen] Add diagnostics stubs for some builting pound syntax 2025-03-20 14:57:41 -07:00
Holly Borla
e2aed1f3d1 [Macros] Remove a print statement from findSyntaxNodeInSourceFile.
This code path isn't on an error path, and the print statement causes
unnecessary build output, which also causes test failures.
2025-03-20 11:37:08 -07:00
Rintaro Ishizaki
92a6fece48 [ASTGen] ObjC improvements
* Generate `#selector(...)` expression
* Generate `#keyPath(...)` expression
* Implicit `@objc` attribute for `@_objcImplementation` attribute
2025-03-20 05:04:58 -07:00
Pavel Yaskevich
561071b5d8 Merge pull request #80126 from xedin/refactor-diagnostic-bridge-to-use-bridged-structs
[DiagnosticBridge] NFC: Refactor `addQueuedDiagnostic` to use Bridged* types instead of pointers
2025-03-20 00:11:18 -07:00
Holly Borla
ab19ad2b54 [Macros] Look for specific syntax node kinds instead of Syntax when
expanding an attached macro.

This fixes a crash in one of the attached macro tests.
2025-03-19 21:45:58 -07:00
Pavel Yaskevich
e456bba910 [DiagnosticBridge] NFC: Switch to use String(bridged:) instead of String(decoding:as:) 2025-03-19 12:04:25 -07:00
Pavel Yaskevich
ac91d39a95 [DiagnosticBridge] NFC: Refactor addQueuedDiagnostic to use BridgedCharSourceRange for diagnostic highlights 2025-03-19 10:18:09 -07:00
Pavel Yaskevich
2ee821164d [DiagnosticBridge] NFC: Refactor addQueuedDiagnostic to use BridgedStringRef instead of plain pointers 2025-03-19 09:54:36 -07:00
Amritpan Kaur
0af27a6354 [ASTGen] Handle keypath methods. 2025-03-19 08:55:47 -07:00
Holly Borla
31d4f661fc [Macros] Support function body macros on closures. 2025-03-18 20:50:47 -07:00
Rintaro Ishizaki
202effd1a3 Merge pull request #80046 from rintaro/old-ownership-spellings
[ASTGen] map oldOwnershipOperatorSpellings feature flag
2025-03-17 14:55:31 -07:00
Jakub Florek
06c131544c Switch to using structs from SwiftLexicalLookup results.
Switch from `lookIn...` to `lookFor...` naming scheme in `LookupResult`.
2025-03-17 20:51:23 +01:00
Rintaro Ishizaki
54da89e4a7 [ASTGen] Handle 'read' and 'modify' accessors 2025-03-16 17:41:21 -07:00