Commit Graph

756 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
7add493002 [ASTGen] Generate '@_spi_available' attribute 2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
d300679aab [ASTGen] Unique "unimplemented" fatal error message 2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
607d122fe9 [ASTGen] Handle several missing syntax
* MissingExpr: Generate ErrorExpr with previous token location
* MissingType: Generate ErrorTypeRepr with previous token location
* MissingPattern: Generate implicit '_' pattern for recovery
2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
ddd5b12661 [ASTGen] Handle trailing where clause in macro declarations 2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
3cdcab23df [ASTGen] MacroExpansionExpr at top-level can be decl 2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
a7b427dea6 Feature oldOwnershipOperatorSpellings 2025-03-16 17:38:07 -07:00
Rintaro Ishizaki
a2e40d6c31 [ASTGen] Generate @_typeEraser attribute 2025-03-16 15:18:59 -07:00
Rintaro Ishizaki
6525d6413c [ASTGen] Generate some renamed atrributes 2025-03-16 15:15:15 -07:00
Rintaro Ishizaki
d1f892cbdc [ASTGen] Generate '@reasync' and '@rethrows'
Also, fallback 'shouldBeRejectedByParser' attribute names to
'CustomAttr'.
2025-03-16 15:14:27 -07:00
Rintaro Ishizaki
3d91c33c14 [ASTGen] Handle 'prefixed(_)' in macro introduced names
'_' is not a 'DeclReferenceExprSyntax', but a
'DiscardAssignmentExprSyntax'.
2025-03-16 15:09:07 -07:00
Rintaro Ishizaki
6a7aacd86c [ASTGen] Fix '@differentiable' attribute
* Typo: '_liner' -> '_linear'
* Accept '@differentiable(_linear)' type attribute
2025-03-16 15:05:49 -07:00
Rintaro Ishizaki
d9f5001311 [ASTGen] Fix location of MagicIdentifierLiteralExpr
It should be the location of '#'.
2025-03-16 15:01:40 -07:00
Rintaro Ishizaki
9fc8bba26d [ASTGen] Fix 'RawDocCommentAttr' generation
* Generate only when 'AttachCommentsToDecls' lang option is enabled.
* Fix the range.
2025-03-16 15:00:29 -07:00
Rintaro Ishizaki
c90768f36e [ASTGen] Fix NamedOpaqueReturnTypeRepr
Generic parameter list was missing
2025-03-16 14:59:43 -07:00
Rintaro Ishizaki
c2146af60f [ASTGen] Fix SendingTypeRepr specifier location 2025-03-16 14:50:21 -07:00
Rintaro Ishizaki
925537180b [ASTGen] Handle 'try' at the first element of SequenceExprSyntax
TryExpr must be hosted to wrap the whole sequence expression.
2025-03-16 14:39:01 -07:00
Rintaro Ishizaki
996e72061a [ASTGen] Gnerate PlaceholderTypeRepr 2025-03-16 14:38:32 -07:00
Rintaro Ishizaki
3a4549b991 Merge pull request #79967 from rintaro/astgen-builtin-pound
[ASTGen] Generate miscellaneous builtin pound
2025-03-14 06:17:37 -07:00
Rintaro Ishizaki
ac80775201 [ASTGen] Generate miscellaneous builtin pound
`#error`, `#warning`, and `#assert`.
Also #_hasSymbol statement condition
2025-03-13 20:28:46 -07:00
Doug Gregor
0e873e723c [Isolated conformances] Change syntax to @<global actor type> P
Instead of using the `isolated P` syntax, switch to specifying the
global actor type directly, e.g.,

   class MyClass: @MainActor MyProto { ... }

No functionality change at this point
2025-03-12 23:18:10 -07:00