Commit Graph

6338 Commits

Author SHA1 Message Date
Hamish Knight
d3be024a54 [IDE] Introduce ReadyForTypeCheckingCallback
This avoids the layering violation of calling `bindExtensions` from
parser code.
2025-09-09 23:18:52 +01:00
Hamish Knight
17fe3de8c7 [Sema] Clean up extension binding a little
- Turn `BindExtensionsForIDEInspectionRequest` into the main extension
binding request.
- Change `ExtendedNominalRequest` such that it's no longer what
extension binding calls into to do the name lookup, instead it calls
directly into `computeExtendedNominal`. `getExtendedNominal` can
then be the entrypoint for `ExtendedNominalRequest` and assumes that
extension binding has already run. This avoids needing to fake the
dependency relationship in the DeclChecker.
2025-09-09 23:18:52 +01:00
Gabor Horvath
7ac9a81b1e [cxx-interop] Add attribute to hide Swift declarations from interop
This can help work around problems when the names of a C++ declaration
and a Swift declaration would collide, or to temporarily work around
compiler bugs.

rdar://152838988&140802127&158843666
2025-09-01 12:29:34 +01:00
Rintaro Ishizaki
a8fba10da1 [Parse] Ignore '(' on newline after attribute names
Also '#error', '#warning', and '#sourceLocation'.

Other call-like syntax (call expression, macro expansion, and custom
attribtues) requires '(' on the same line as the callee. For consistency,
built-in attributes and built-in directives should also ignore '(' on
next line.
2025-08-24 19:20:33 -07:00
Hamish Knight
114ea293c4 Merge pull request #82058 from a7medev/feat/access-control-set-fix-it
[Diagnostics] Add fix-its for missing `set` and `)` after access modifier
2025-08-16 18:42:28 +01:00
Ahmed Mahmoud
df0eda93f4 [IDE] Update comments for access control missing set fix-its 2025-08-15 15:23:29 +03:00
Hamish Knight
acf6375d46 Introduce BindExtensionsForIDEInspectionRequest
This allows us to lazily bind extensions after mutating the AST,
ensuring we don't prematurely kick the building of lookup tables.
2025-08-10 23:49:03 +01:00
Ahmed Mahmoud
3cd3c048cf [Diagnostics] Add fix-its for missing set and ) of access modifier 2025-08-10 01:57:02 +03:00
Hamish Knight
396a6a8fe6 Enable InlineArray type sugar
Promote it from an experimental feature.

rdar://155607927
2025-08-04 15:16:30 +01:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Anthony Latsis
06a5670c8f Basic: Untie swift::SourceLoc from llvm::SMLoc
Storing a `llvm::SMLoc` is a superfluous indirection, and getting rid of
it enables us to unconditionally import `SourceLoc` into Swift.
2025-07-11 18:48:42 +01:00
Pavel Yaskevich
43eec8fede [AST/Sema] SE-0487: Expand @nonexhaustive attribute to support warn argument
The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.
2025-07-04 10:20:25 -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
Hamish Knight
01aa746840 Merge pull request #82568 from hamishknight/mac-n-cheese 2025-06-28 09:16:53 +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
Hamish Knight
8d1c1bfe2d [IDE] Bail from IDEInspectionSecondPassRequest if parserState is null
This shouldn't ever happen, but let's at least make sure we don't
crash.
2025-06-27 18:30:06 +01:00
Andrew Trick
080b68292d Fix a compiler crash with '@'_lifetime(inout x), add diagnostic
This is a common mistake made more common be suggestions of existing diagnostic
that tell users not to use a 'copy' dependency.

Report a diagnostic error rather than crashing the compiler. Fix the diagnostic
output to make sense relative to the source location.

Fixes rdar://154136015 ([nonescapable] compiler assertion with @_lifetime(x: inout x))
2025-06-25 16:34:43 -07:00
Anthony Latsis
3e9923f0c0 ASTBridging: Bridge swift::AccessorKind directly 2025-06-19 04:26:52 +01:00
Slava Pestov
cfa9de8f0a Parse: Address an llvm_unreachable that is actually reachable 2025-06-17 10:15:30 -04:00
Slava Pestov
908c9368ed Parse: Only accept certain literals as enum case raw values
Just checking for LiteralExpr is too broad, because Sema doesn't
know what to do with RegexLiteralExpr for example.
2025-06-17 09:19:00 -04:00
Alexis Laferrière
2601ff44d4 Parser: Accept @cdecl with an indentifier for the C name
Begin accepting the attribute in the form of `@cdecl(cName)`, using an
identifier instead of a string.

For ease of landing this change we still accept the string form. We
should stop accepting it before making this feature available in
production.
2025-06-11 12:42:38 -07:00
Meghana Gupta
dcf072f9d0 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-07 12:49:07 -07:00
Meghana Gupta
0dfa1fc312 Update spelling for representing lifetime dependencies to @_lifetime 2025-06-07 12:49:07 -07:00
Allan Shortlidge
14341285cb Parse: Fix unused variable warning. 2025-06-03 09:45:46 -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
21ec5924f7 [AST] NFC: Capitalize UsingSpecifier::nonisolated for consistency 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
ec9132cb5a [Diagnostics] Tailor using diagnostic to current use-case - default isolation 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
c246a7a372 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
4ad27ba61e [Parse] Implement parsing for using declarations 2025-05-31 10:49:45 -07:00
Slava Pestov
f6f0d75263 Merge pull request #81843 from slavapestov/hamish-fuzzer-fixes
Hamish fuzzer fixes
2025-05-31 12:28:56 -04:00
Slava Pestov
6d0c73935b Parse: An empty escaped identifier is entirely whitespace 2025-05-30 16:27:00 -04:00
Slava Pestov
ff941bc4f3 Sema: Fix crash when any is followed by something that doesn't parse as a type 2025-05-30 14:44:58 -04:00
Hamish Knight
5d1f219acb Change InlineArray sugar separator x -> of 2025-05-30 13:50:22 +01:00
Arnold Schwaighofer
7ac551636b Merge pull request #81714 from aschwaighofer/se0460
SE-0460: Introduce @specialized attribute
2025-05-28 12:03:48 -07: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
Rintaro Ishizaki
6f24696878 Merge pull request #81612 from calda/cal--trailing-comma-missing-from-6.1
Add trailing comma support in cases missing from Swift 6.1
2025-05-22 11:30:28 -07:00
Cal Stephens
9a3f33de8e Support trailing commas in types within expressions 2025-05-19 18:56:53 -07:00
Cal Stephens
9072d860d9 Revert changes to trailing commas in attributes like @available 2025-05-19 16:00:42 -07:00
Cal Stephens
1a3d71cc53 Add trailing comma support in cases missing from Swift 6.1 2025-05-19 09:19:49 -07:00
Pavel Yaskevich
04d46760bb [AST] Extend @_inheritActorContext attribute to support optional always modifier
By default (currently) the closure passed to a parameter with `@_inheritActorContext`
would only inherit isolation from `nonisolated`, global actor isolated or actor
context when "self" is captured by the closure. `always` changes this behavior to
always inherit actor isolation from context regardless of whether it's captured
or not.
2025-05-14 20:07:57 -07:00
Hamish Knight
e0ceb85c6a [AST] Remove unparsed case from FuncDecl::getSourceRange
This wasn't really sound since it could result in source ranges that
have different buffers for the start and end loc. Instead, adjust
the parser logic to look at the brace range.
2025-05-14 11:15:42 +01:00
Hamish Knight
3c67271869 [AST] Handle a few more cases in getStartLoc()
Handle PatternBindingDecls with missing var locations, which can
happen for loop iterator vars, and FuncDecls with missing name and
func locations, which can happen for `defer`. Also while here make
sure we set the source location of a parser-produced ErrorExpr.
2025-05-14 11:15:42 +01:00
shiz
d12cb84586 [Parse] Avoid parsing unsafe expression before binary or postfix op (#81429)
rdar://150751248
2025-05-14 10:02:58 +01:00
Rintaro Ishizaki
682d2634ba [Parse] Parse operator function with value generics
Operator function parsing has a heuristics to determine if `<` a part of
the operator name or the generic parameter clause. Handle `let` there
because value generics uses it.

rdar://149556573
2025-05-02 17:09:13 -07:00
Rintaro Ishizaki
533ae2b994 Merge pull request #80928 from kntkymt/kntk-trailing-comma-string-interpolation
[Parser] Fix String interpolation accepts invalid argument label syntax without expression
2025-04-22 01:38:50 +09:00
kntkymt
af6b4ad7a1 [Parser] fix parse trailing commna in string interpolation at the end of parseListItem flow instead 2025-04-19 14:36:11 +09:00
Becca Royal-Gordon
25bf069ce3 [Legacy parser] No freestanding macros in @abi
SwiftSyntaxParser is already doing this, and we already diagnosed it in Sema anyway, so we’re just moving that diagnostic earlier so the ASTGen testing mode is happy. Also adding compiler tests for it.

Macro-related tests are not included in this commit; they require matching swift-syntax changes which are being negotiated.
2025-04-18 14:50:01 -07:00
Alexis Laferrière
a6beaf8deb Merge branch 'main' into cdecl-global-function-checking 2025-04-16 11:19:37 -07:00
Doug Gregor
3380331e7e [SE-0470] Enable isolated conformances by default
The IsolatedConformances feature moves to a normal, supported feature.
Remove all of the experimental-feature flags on test cases and such.

The InferIsolatedConformances feature moves to an upcoming feature for
Swift 7. This should become an adoptable feature, adding "nonisolated"
where needed.
2025-04-13 15:41:53 -07:00
Pavel Yaskevich
f00d8082db [Parse] Tighten constraints in canParseNonisolatedAsTypeModifier
Accept it only if it's spelled `nonisolated(nonsending)` and nothing
else to minimize any possible source compatibility impact.
2025-04-11 15:59:25 -07:00