Commit Graph

198 Commits

Author SHA1 Message Date
Allan Shortlidge c7ce5a8aed Parse: Allow availability macros to contain empty expansions.
In some cases, it's useful to allow an availability macro to expand to an empty
availability specification list. Allow developers to express this using macros
that are defined to exactly the string `*`, while continuing to reject `*` in
availability macros that contain other entries.
2026-03-02 12:14:29 -08:00
Rintaro Ishizaki fbad8aaf8f Merge pull request #87259 from ramonasuncion/test-astgen-availability-define-directive
[Test][ASTGen] Use DEFINE directive to deduplicate availability args
2026-03-01 07:14:48 -08:00
Allan Shortlidge acec1015b8 test: Remove -disable-availability-checking in ASTGen tests. 2026-02-25 09:25:30 -08:00
Ramon Asuncion 7a530bf777 [Test][ASTGen] Use DEFINE directive to deduplicate availability args 2026-02-16 11:43:15 -05:00
Slava Pestov 1b918ded02 Merge pull request #86163 from youngbash88/fix-54030
[Sema] Move anonymous closure argument check from parser to semantic analysis
2026-02-04 02:03:50 -05:00
Ramon Asuncion ca304e028c [Test][ASTGen] Inline COMPILER_ARGS in availability tests 2026-01-09 13:59:19 -05:00
bashir 176229aeb4 [Sema] Move anonymous closure argument check from parser to semantic analysis 2025-12-22 01:35:04 +02:00
Kavon Farvardin 314093f426 SILGen: add RValue emission for BorrowExpr 2025-11-07 14:01:35 -08:00
Alexis Laferrière 94113f4a83 SE-496: Remove references to features CDecl and CImplementation 2025-10-29 17:31:20 -07:00
Kuba Mracek adeb40f261 SE-0492: Stabilize @_section/@_used into @section/@used
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492.

Major parts:
- Renamed @_section to @section and @_used to @used
- Removed the SymbolLinkageMarkers experimental feature
- Added parsing support for the old underscored names with deprecation warnings
- Updated all tests and examples to use the new attribute names
- Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm)
- Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules
- Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
2025-10-22 16:05:39 -07:00
Rintaro Ishizaki 7a4b7aa92a [ASTGen] Update for UnexpectedCodeDeclSyntax addition 2025-09-27 12:04:09 -07:00
Alexis Laferrière 9ec824c20b Parser: Rename the experimental attribute @cdecl to @c
There's no users of `@cdecl` yet so we can do a direct rename. The
legacy `@_cdecl` remains unaffected.
2025-09-19 11:55:07 -07:00
Slava Pestov 0507b02024 RequirementMachine: Fix crash-on-invalid with concrete type requirements involving packs
We would crash in some cases, or produce a slightly misleading
diagnostic about same-element requirements, which are related but
not quite the same.

In the fullness of time, we should figure out this corner of the
language. Until then, add a new diagnostic since this is really
about same-type requirements between concrete types and packs.

Fixes rdar://159790557.
2025-09-10 20:20:31 -04:00
Rintaro Ishizaki 7cfc5aa93b [ASTGen/Tests] Add 'REQUIRES: string_processing'
This test imports _StringProcessing implicitly

rdar://159635602
2025-09-09 10:48:10 -07:00
Allan Shortlidge c958ed3254 Tests: Remove REQUIRES: executable_test from ASTGen/attrs.swift.
It is not an executable test.

Resolves rdar://159025990.
2025-08-26 14:37:44 -07:00
Allan Shortlidge 4d41db3b5d Sema: Rationalize availability checking in unavailable contexts.
Correct several behaviors of availability checking in unavailable contexts that
were inconsistent with the checking model:

- Avoid diagnosing unintroduced and obsolted declarations in contexts that are
  unavailable in the same domain.
- Diagnose unavailability normally in type signature contexts.
2025-08-08 07:57:44 -07:00
Hamish Knight 396a6a8fe6 Enable InlineArray type sugar
Promote it from an experimental feature.

rdar://155607927
2025-08-04 15:16:30 +01:00
Allan Shortlidge 67d784fbaf Sema: Diagnose invalid platform versions in @_originallyDefinedIn.
Part of rdar://155558161.
2025-07-14 16:40:09 -07:00
Hamish Knight a3eed77738 [Parse] Fix isEditorPlaceholder checks in the parser
Factor out `Token::isEditorPlaceholder` and make sure we're checking
the token's raw text, ensuring we don't ignore backticks.
2025-06-30 21:16:22 +01:00
Alexis Laferrière 81a0f98783 Merge pull request #82194 from xymus/cdecl-parser
Parser: Accept `@cdecl` with an optional identifier for a custom C name
2025-06-27 15:06:11 -07:00
Alexis Laferrière d9566c6c1e ASTGen: Accept @cdecl 2025-06-11 12:42:38 -07:00
Meghana Gupta 44e05fa858 [NFC] Update tests and diagnostics 2025-06-07 12:49:01 -07:00
Pavel Yaskevich e1e9f04398 Merge pull request #81863 from xedin/using-for-default-isolation-in-file-context
[AST/Sema] SE-0478:  Implement `using` declaration under an experimental flag
2025-06-02 09:56:29 -07:00
Pavel Yaskevich c246a7a372 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature 2025-05-31 10:49:50 -07:00
Pavel Yaskevich 4b5105df5e [ASTGen] Implement bridging for using declaration 2025-05-30 15:52:09 -07:00
Hamish Knight 5d1f219acb Change InlineArray sugar separator x -> of 2025-05-30 13:50:22 +01:00
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 17b8f7ef12 [Sema] Validate that @_inheritActorContext is used only on @Sendable/sending and async/@isolated(any) parameters 2025-05-14 20:08:00 -07:00
Pavel Yaskevich c0aca5384b [ASTGen] Transform @_inheritActorContext into a custom attribute with an optional modifier 2025-05-14 20:07:59 -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 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 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 4b8c8e7d72 [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-11 12:08:29 -07:00
Becca Royal-Gordon 3baba0b262 Type check @abi decls (sans attrs)
This commit compares the decl inside the `@abi` attribute to the decl it’s attached to, diagnosing ABI-incompatible differences. It does not yet cover attributes, which are a large undertaking.
2025-03-26 10:47:13 -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
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
Andrew Trick 64a48d08e1 Update tests for strict @lifetime type checking 2025-03-19 11:59:04 -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
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 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 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 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 c90768f36e [ASTGen] Fix NamedOpaqueReturnTypeRepr
Generic parameter list was missing
2025-03-16 14:59:43 -07:00
Rintaro Ishizaki bc668b6232 [ASTGen] Fix nullability
For 'arbitrary' macro names
2025-03-16 14:48:00 -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