Commit Graph

2357 Commits

Author SHA1 Message Date
Artem Chikin
cc34ba00e2 [Dependency Scanning] Disable Swift Parser ASTGen during dependency scan
On both input moduel source-files and interface files.
This currently yields dramatic scanning performance improvements at no cost - we do not require an AST during scan.
2023-03-31 15:49:54 -07:00
Alex Hoppen
5bb6f79847 Merge pull request #64609 from ahoppen/ahoppen/no-self-macros
[Macros] Disallow `self` and `Self` as macro names
2023-03-27 11:23:19 -07:00
Doug Gregor
c31f6fa0cc Merge pull request #64631 from DougGregor/macro-parameter-defaults 2023-03-27 06:50:08 -07:00
Doug Gregor
9d9f8326c8 [Macros] Allow macro parameters to have default arguments.
SE-0382 allows macro parameters to have default arguments. Enable these
default arguments, with the normal type checking rules. One
significant quirk to this implementation is that the actual default
argument values don't make it to the macro implementation. This is a
previously-unconsidered design problem we'll need to address.

Tracked by rdar://104043987.
2023-03-26 22:13:37 -07:00
Kim de Vos
8fb787dc27 Downgrade placeholder error to warning for swiftparser 2023-03-24 20:18:02 +01:00
Alex Hoppen
d5a90174f0 [Macros] Disallow self and Self as macro names
We were allowing `self` and `Self` as freestanding macro names, which we don’t want.
2023-03-24 09:32:51 -07:00
Alex Hoppen
6c5ac5179a Merge pull request #63490 from ahoppen/ahoppen/split-ideinspection
Split IDEInspectionCallbacks into CodeCompletionCallbacks and DoneParsingCallback
2023-03-20 09:20:30 -07:00
Saleem Abdulrasool
b52fdb9d4b Apply suggestions from MSVC workaround 2023-03-18 14:11:31 -07:00
Alex Hoppen
024e2c93af [Parse] Add curly braces
Maybe this makes VSCode happy and resolves a Windows-only compilation failure `error C2059: syntax error: ')'`
2023-03-17 13:40:56 -07:00
Alex Hoppen
8a2cd86deb Split IDEInspectionCallbacks into CodeCompletionCallbacks and DoneParsingCallback
Cursor info only cares about the `doneParsing` callback and not about all the `complete` functions that are now defined in `CodeCompletionCallbacks`. To make the design clearer, split `IDEInspectionCallbacks`.

rdar://105120332
2023-03-17 10:31:13 -07:00
Ellie Shin
77b5c79cc0 Allow package(set) at the top level decl site
Treat `package` as a non-contextual keyword when applicable
Add tests
Resolves rdar://105978922, rdar://104931420
2023-03-16 17:38:18 -07:00
Michael Gottesman
40449a6987 [move-only] Emit a clearer message around deinits.
Specifically:

1. Fix the error message so that when we say you can't have a deinit that a
deinit can be on a noncopyable type along side a class or an actor.

2. Even though we already error on @objc enums and say they cannot be
noncopyable, we did not emit an error on the deinit saying that @objc enums
cannot have a deinit. I put in a nice to have error just to make it even
clearer.

rdar://105855978
rdar://106566054
2023-03-12 14:47:34 -07:00
Doug Gregor
ef7f707fcc Revert "Improve @objcImplementation member checking" 2023-03-10 12:00:33 -08:00
Sophia Poirier
739cc2a66c Merge pull request #64104 from sophiapoirier/type-parameter-pack-syntax-each-diagnostics
[Variadic Generics] fix diagnostics dangling reference and fixits for…
2023-03-06 14:27:37 -08:00
Ben Barham
edb980eb55 Merge pull request #64095 from bnbarham/do-not-change-refactoring
[Macros] Do not edit macro buffer or position when refactoring
2023-03-06 08:43:30 -08:00
Xi Ge
ffc998a0e7 Merge pull request #63668 from beccadax/checkmate
Improve @objcImplementation member checking
2023-03-06 08:21:59 -08:00
Richard Wei
833338f9ce [Macros] Top-level freestanding macros (#63553)
Allow freestanding macros to be used at top-level.
- Parse top-level `#…` as `MacroExpansionDecl` when we are not in scripting mode.
- Add macro expansion decls to the source lookup cache with name-driven lazy expansion. Not supporting arbitrary name yet.
- Experimental support for script mode and brace-level declaration macro expansions: When type-checking a `MacroExpansionExpr`, assign it a substitute `MacroExpansionDecl` if the macro reference resolves to a declaration macro. This doesn’t work quite fully yet and will be enabled in a future fix.
2023-03-06 07:15:20 -08:00
Sophia Poirier
cdde853663 [Variadic Generics] fix diagnostics dangling reference and fixits for parameter pack syntax change: T... -> each T 2023-03-04 10:01:16 -08:00
Ben Barham
80d27128d8 [Macros] Do not edit macro buffer or position when refactoring
Rather than editing the macro buffer in refactoring, add appropriate
padding and braces when creating the macro.

Don't edit the insertion location - we should update this in a later PR
as well.
2023-03-03 19:48:06 -08:00
Becca Royal-Gordon
2c0abf0362 Better support destructors in objcImpl 2023-03-03 17:27:39 -08:00
Michael Gottesman
78d57ea6be [reference-bindings] Put reference bindings support behind -enable-experimental-feature ReferenceBindings. 2023-03-03 17:14:16 -08:00
Ben Barham
f3a6ce144c Merge pull request #63906 from bnbarham/add-nested-expansion
[Refactor] Allow expanding nested macros
2023-03-02 20:43:35 -08:00
Doug Gregor
4d3f1fa67b Merge pull request #64044 from DougGregor/macros-feature-flags
Clean up feature flags for macros.
2023-03-02 19:03:32 -08:00
Doug Gregor
f88d2c638f Clean up feature flags for macros.
Enable expression macros by default, and add separate feature flags for
attached and freestanding macros.
2023-03-02 14:34:59 -08:00
Ben Barham
bb7760b9e0 [Refactor] Allow expanding nested macros
This adds a new `primary_file` key, which defaults to `sourcefile`. For
nested expansions, `primary_file` should be set to the containing file
and `sourcefile` to the name of the macro expansion buffer.
2023-03-02 14:04:46 -08:00
Michael Gottesman
c97121d3ee [reference-binding] Add support for inout binding parsing/serialization. 2023-03-01 20:48:54 -08:00
Michael Gottesman
4b354f6132 [reference-binding] Make InBindingState into a true type called PatternBindingState.
This cleans up the parser code a little bit around here and will make it easier
for me to add inout.
2023-03-01 20:48:33 -08:00
Joe Groff
17c803724f Implement consuming and borrowing declaration-level modifiers from SE-0377.
`borrowing func`/`consuming func` control the ownership convention of `self` for
methods.
2023-03-01 11:58:59 -08:00
Joe Groff
704a4363d7 C++ parser: support borrowing and consuming modifiers.
And adjust contextual parameter modifier parsing in general to be more
properly contextual, so we don't have to reserve `__shared` or `__owned`,
or their successor spellings, as argument labels anymore.
2023-02-28 09:16:45 -08:00
Joe Groff
655e9e681d Add ParamSpecifier cases for Borrowing and Consuming.
And do a first pass of auditing existing uses of the parameter specifiers to
make sure that we look at the ValueOwnership mapping in most cases instead of
individual modifiers.
2023-02-28 09:16:44 -08:00
Holly Borla
a3caacd309 [Macros] Initial implementation of conformance macros. 2023-02-23 20:43:11 -08:00
Alex Hoppen
8bdf68d483 [IDE] Check whether an AST node contains the IDE inspection point based on CharSourceRange
This fixes an issue if the range ends with a string literal that contains the IDE inspection target. In that case the end of the range will point to the start of the string literal but the IDE inspection target is inside the string literal and thus after the range’s end.
2023-02-20 15:37:38 +01:00
Holly Borla
f04f512184 [Macros] Add a new macro role for attached peer macros. 2023-02-10 14:38:22 -08:00
Doug Gregor
04eca73d60 [Macros] Stop parsing the ": <type>" syntax. We always require parameters 2023-02-09 22:11:23 -08:00
Doug Gregor
bf61578f81 [Macros] Don't assert when a macro parameter has a default argument 2023-02-08 14:34:11 -08:00
Richard Wei
01e4c8df26 [Macros] Use name lookup for lazy declaration macro expansion (#63411)
- Use the name lookup table instead of adding members from a macro expansion to the parent decl context.
- Require declaration macros to specify introduced names and used the declared names to guide macro expansions lazily.
2023-02-07 11:24:42 +08:00
Ellie Shin
258b13b05d Merge pull request #63355 from apple/es-export-pr
Add access level and scope checks to package types
2023-02-03 15:20:29 -08:00
Ellie Shin
be20333a87 Add access level and scope checks to package types
Resolves rdar://104617227
2023-02-02 16:51:17 -08:00
Allan Shortlidge
8fde58f6ca Merge pull request #63357 from tshortli/se0376-rename-backdeploy
[SE-0376] Rename `@_backDeploy(before:)` to `@backDeployed(before:)`
2023-02-02 12:36:53 -08:00
Alex Hoppen
d54af66b50 [Parser] When performing parser validation, suppress warnings from SwiftParser
We can get into a situation where the C++ parser has emitted a warning but no error and thus `hadAnyError()` is still `false`. Suppress warnings from SwiftParser to avoid emitting the same warning that we already emitted from the C++ parser from SwiftParser.
2023-02-02 16:50:04 +01:00
Allan Shortlidge
d2524a6de8 AST: Implement parsing support for the accepted spelling of @backDeployed for SE-0376.
For source compatibility `@_backDeploy` continues to be accepted as a spelling.

rdar://102792909
2023-02-01 22:04:33 -08:00
John McCall
ea107ae025 Merge pull request #63324 from rjmccall/element-archetype-printing
Fix printing and implement parsing of opened element archetypes in SIL
2023-02-01 18:59:54 -05:00
John McCall
c491d25d06 Fix printing and implement parsing of opened element archetypes in SIL
Also, fix a couple places that were checking for opened existentials
to check for any local archetype.
2023-01-31 19:54:31 -05:00
Anthony Latsis
3302b27df8 Merge pull request #62775 from AnthonyLatsis/sugar-type-members-2
Parser: Support member types with non-identifier qualifiers
2023-02-01 02:07:12 +03:00
Holly Borla
e6d7ea53ed [Parser] Use proper ParseDeclOptions when parsing the result of a member macro
expansion.
2023-01-27 22:37:22 -08:00
Holly Borla
32a0705e90 [Macros] Use the singular 'memberAttribute' spelling for attached member
attribute macros.
2023-01-26 21:52:39 -08:00
Holly Borla
f6f57a8099 [Macros] Rename "synthesized member macros" to "member macros". 2023-01-26 21:52:36 -08:00
Anthony Latsis
fe047b98fb Parser: Tweak parseTypeIdentifier to better suit its only remaining client 2023-01-26 21:22:18 +03:00
Doug Gregor
af7ce9e945 [Macros] Remove the @declaration attribute.
We have @freestanding working appropriately now.
2023-01-25 17:07:38 -08:00
Doug Gregor
c188ab4f91 Remove the "@expression" attribute now that it has a better spelling 2023-01-25 17:07:38 -08:00