Commit Graph

2392 Commits

Author SHA1 Message Date
Angela Laar
3eb2b1c67b Fix error definition 2022-01-13 13:53:50 -08:00
Angela Laar
68ec09b7e2 [Parser] Check for postfix operator in import paths
Add diagnostic and remove operator from path
Fixes rdar://87159294
2022-01-12 18:18:16 -08:00
Luciano Almeida
91966deeb7 Merge pull request #40705 from LucianoPAlmeida/SR-15657-diag-enum-cp
[Sema] Avoid misleading diagnostics for incomplete enum computed properties
2022-01-11 09:25:19 -03:00
Doug Gregor
43324e8130 Merge pull request #40710 from DougGregor/structural-opaque-result-types 2022-01-04 20:51:14 -08:00
LucianoAlmeida
29879ea822 [Parser] Improving wording for invalid empty computed properties and subscripts 2022-01-04 23:46:09 -03:00
Doug Gregor
b2aa85183d Use TypeRepr::hasOpaque() consistently.
Replace shallow checks for `OpaqueReturnTypeRepr` with calls to
`hasOpaque`, which ensures that we consider opaque result types in
structural positions.
2021-12-27 20:11:40 -08:00
Evan Wilde
319672d084 Merge pull request #40668 from etcwilde/ewilde/an-actor-for-your-thoughts
Fix miss-parse diagnostic to say "actor"
2021-12-22 08:16:59 -08:00
Rintaro Ishizaki
7c92a8e555 [SourceKit] Add a request to generate object files in SourceKit
Add 'request.compile'
2021-12-21 14:35:38 -08:00
Evan Wilde
c61ae352b1 Fix miss-parse diagnostic to say "actor"
Diagnostic for miss-parsing actors for missing '{' and '}' would say
"class" instead of "actor". This patch fixes it.
2021-12-21 14:00:14 -08:00
Evan Wilde
b15adeab4f Merge pull request #40601 from etcwilde/ewilde/no-main-in-sil
Don't emit `@main` into SIL
2021-12-17 07:21:22 -08:00
Evan Wilde
86d4f83de9 Make @main non-simple
We want to control when the attribute gets emitted so we need to make
the attribute non-simple.
2021-12-16 16:31:15 -08:00
Robert Widmann
6f8f19e17f Use Recovery-Provided Variable When Parsing 'async' 2021-12-13 12:26:03 -08:00
Evan Wilde
aa9085a3d8 Handle attr parse failures
Adding nice error messages for when things go wrong.
2021-12-08 09:39:24 -08:00
Evan Wilde
3a13721eae Add optional message to unavailablefromasync
Adding the ability to add an optional message to the unavailable from
async attribute. This can be used to indicate other possible API to use,
or help explain why it's unavailable.
2021-12-08 09:39:24 -08:00
Saleem Abdulrasool
349af3707d Merge pull request #40305 from compnerd/semitruck
gardening: make c++98-compat-extra-semi an error
2021-11-30 08:18:36 -08:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Xi Ge
06e63896cd ModuleInterface: consume _const keyword at var and parameter decls and keep them in textual/binary modules
This is to ensure users can start adding these annotations. Type checker supports will come in later commits.

Related to pitch: https://forums.swift.org/t/pitch-compile-time-constant-values/53606

rdar://85268028
2021-11-19 22:13:23 -08:00
Doug Gregor
5cc00c289d Remove the @_unsafeSendable/@_unsafeMainActor attributes.
These have been subsumed by @_predatesConcurrency. Leave in minimal
parser support that warns about the removal, so we don't fully break
existing source code.
2021-11-18 11:21:03 -08:00
Ellie Shin
89fb5ff3fc Merge branch 'main' into es-param 2021-11-08 17:55:25 -08:00
Ellie Shin
06683cda43 Add module alias lookup option enum
Pass the enum param to ASTContext::getRealModuleName
2021-11-08 17:51:27 -08:00
Robert Widmann
f807dfe9e3 Parse @_typeSequence in Generic Parameter Position
Stage in the parsing for this attribute, nothing else.

Motivated by two important reasons:

1) The pitch for variadic generics does not lay down a concrete syntax
   for variadic generic parameters.
2) Paring T... and T* needlessly complicate the lexer as we must now
   disambiguate them with respect to other internal operator characters
   (e.g. `T...>` must lex as `(T...)>` and not `T ...>`

Which itself adds another motivation

3) We need to start parsing this attribute *now* to avoid condfail'ing
   ourselves later.
2021-11-02 14:42:12 -07:00
Ellie Shin
b294fe94f2 Merge pull request #39929 from apple/es-src
Module Aliasing: do not allow module real names to appear in source files (only allow module aliases).
Resolves rdar://83592084
2021-11-01 17:50:49 -07:00
Karoy Lorentey
8ea88b7582 [Parse] Register a syntax context while parsing availability macros 2021-10-31 17:14:35 -07:00
Ellie Shin
66d64b610d Updates params to ASTContext::getRealModuleName 2021-10-29 01:52:33 -07:00
elsh
daf07c0306 Update getRealModuleName
Assert map is empty in setModuleAliases
Update doc comments
2021-10-28 23:43:16 -07:00
Ellie Shin
470fbc7223 Update lib/Parse/ParseDecl.cpp
Co-authored-by: Becca Royal-Gordon <beccadax@apple.com>
2021-10-28 23:03:33 -07:00
elsh
257ae1bbf9 Update comments 2021-10-28 03:02:24 -07:00
elsh
10a96dff57 Module Aliasing: do not allow module real names to appear in source files / only allow aliases
Resolves rdar://83592084
2021-10-28 02:36:59 -07:00
Becca Royal-Gordon
354f3470a0 Add @_nonSendable decl attribute
This attribute creates an unavailable extension with a `Sendable` conformance so that the type is explicity marked as not being `Sendable`.

We also fully suppress diagnostics about unavailable Sendable conformances in Swift 5 mode code. (This is not fully developed yet—it should return to being a warning in concurrent contexts.)

The behavior when a @_nonSendable and a Sendable conformance are both on the same type is also not right yet.
2021-10-14 12:14:46 -07:00
Becca Royal-Gordon
19f15fffdf [NFC] Refactor attribute option parsing 2021-10-13 14:13:46 -07:00
Arnold Schwaighofer
c2b2f1331f SIL representation 2021-10-06 04:54:49 -07:00
Arnold Schwaighofer
71f46a4f25 Add support to syntax tree 2021-10-06 04:54:41 -07:00
Arnold Schwaighofer
8840ea6b5b Add support for parsing an availability argument in @_specialize 2021-10-05 14:46:17 -07:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
Hamish Knight
dc60996f89 Merge pull request #38836 from hamishknight/toil-and-tuple 2021-09-04 19:30:04 +01:00
Hamish Knight
a5775482ee [Parser] Adopt ArgumentList
Split up the expr list parsing members such that
there are separate entry points for tuple and
argument list parsing, and start using the argument
list parsing member for call and subscripts.
2021-09-01 18:40:24 +01:00
jiaren wang
d8780d33e9 [Parse] give more useful errors for forget 'do' keyword. 2021-09-01 21:18:56 +08:00
Rintaro Ishizaki
49547a5378 [NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace
Just for convenicence.

* Replace `llvm::isa_and_nonnull` with imported `isa_and_nonnull`
* Repalce some `EXPR && isa<T>(EXPR)` with `isa_and_nonnull<T>(EXPR)`
2021-08-27 11:36:21 -07:00
Konrad `ktoso` Malawski
fbd66e2b87 [Distributed] Only parse distributed when experimentla mode enabled 2021-08-16 18:11:06 +09:00
Becca Royal-Gordon
627ecbdfff Rip designated types out of the AST
Designated types were removed from the constraint solver in #34315, but they are currently still represented in the AST and fully checked. This change removes them as completely as possible without breaking source compatibility (mainly with old swiftinterfaces) or changing the SwiftSyntax tree. Designated types are still parsed, but they are dropped immediately and a warning is diagnosed. During decl checking we also still check if the precedence group is really a designated type, but only so that we can diagnose a warning and fall back to DefaultPrecedence.

This change also fixes an apparent bug in the parser where we did not diagnose operator declarations that contained a `:` followed by a non-identifier token.
2021-08-03 16:13:59 -07:00
Ben Barham
e7e9b57051 Replace @completionHandlerAsync with @available(*, renamed:)
Instead of a new attribute `@completionHandlerAsync`, allow the use of
the existing `renamed` parameter of `@available` to specify the
asynchronous alternative of a synchronous function.

No errors will be output from invalid names as `@completionHandlerAsync`
had, but if a function is correctly matched then it will be used to
output warnings when using the synchronous function in an asynchronous
context (as before).

Resolves rdar://80612731
2021-07-29 09:14:44 +10:00
Varun Gandhi
db35cab089 Merge pull request #33932 from rockbruno/negative-aval
[SE-0290] Add #unavailable (Negative platform checks)
2021-07-13 16:17:17 -07:00
Doug Gregor
06bbc70b3e Module printing and serialization support for @unchecked Sendable 2021-07-11 12:29:54 -07:00
Bruno Rocha
1fe3857735 [SE-0290] Add #unavailable 2021-07-02 13:35:11 +02:00
Doug Gregor
4fc23332f1 Merge pull request #37986 from DougGregor/parse-closure-attributes-and-captures
[Parser] Allow closures with custom attributes and capture lists.
2021-06-23 22:39:58 -07:00
Doug Gregor
c73732769d [Parser] Allow closures with custom attributes and capture lists.
The parsing of Swift 1.0 beta-1 array syntax (e.g., `Int [something]`)
was preventing closures with both a custom attribute (e.g.,
`@MainActor) and a capture list from parsing correctly. Don't parse
that syntax within custom attributes.

Fixes rdar://77303587.
2021-06-18 22:15:40 -07:00
Doug Gregor
6ba26292b1 [Clang importer] Import Swift declaration modifiers from swift_attr.
In addition to importing Swift attributes spelled with the C
`__attribute__((swift_attr("...")))`, also import declaration modifiers,
including `nonisolated`.

Fixes rdar://79402200.
2021-06-17 10:25:42 -07:00
Doug Gregor
bd8626fa1b [Concurrency] Parse and add 'isolated' parameters to the type system. 2021-06-07 23:59:38 -07:00
Doug Gregor
b09c55aa48 Temporarily allow @actorIndependent as an alias for nonisolated.
Addresses rdar://78830857.
2021-06-03 14:03:58 -07:00
Doug Gregor
03f55d7bb4 Revert "Revert "Remove @actorIndependent attribute.""
This reverts commit 7c0b50e8ea.
2021-06-03 14:03:57 -07:00