Commit Graph

2392 Commits

Author SHA1 Message Date
Rintaro Ishizaki
64dab42e96 Merge pull request #26670 from rintaro/syntax-parse-sil-else
[Syntax] Create UnknownDecl node for orphan #else, et al. and SIL nodes
2019-08-16 07:03:59 +02:00
Rintaro Ishizaki
223de71ad3 [Syntax] Create UnknownDecl node for orphan #else, et al. and SIL nodes 2019-08-16 00:59:20 +00:00
Slava Pestov
70bcd74ed0 Sema: Introduce IsImplicitlyUnwrappedOptionalRequest 2019-08-15 18:41:42 -04:00
Slava Pestov
1c3ac86796 AST: Banish OptionalTypeKind to ClangImporter.h
The only place this was used in Decl.h was the failability kind of a
constructor.

I decided to replace this with a boolean isFailable() bit. Now that
we have isImplicitlyUnwrappedOptional(), it seems to make more sense
to not have ConstructorDecl represent redundant information which
might not be internally consistent.

Most callers of getFailability() actually only care if the result is
failable or not; the few callers that care about it being IUO can
check isImplicitlyUnwrappedOptional() as well.
2019-08-15 18:41:42 -04:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Slava Pestov
94149db4ec Parse: Record which delayed type and extension bodies possibly contain operators and classes
To properly delay parsing type and extension bodies we need to know
which ones might contain nested operator and class definitions, since
they must be known upfront when building the global operator lookup
and AnyObject dispatch lookup tables, respectively.

To guess if the type contains operator definitions, we look for the
'func' keyword followed by an operator token.

To guess if the type contains class definitions, we look for the
'class' keyword.

For now, this information is recorded but not used. Subsequent commits
will make use of this information to delay parsing in more cases.
2019-08-12 17:15:51 -04:00
swift-ci
c43eb9b1d8 Merge pull request #26418 from nathawes/type-attr-coloring 2019-08-09 13:47:29 -07:00
Arnold Schwaighofer
5079f1e6de Don't emit a warning to import Foundation for dynamic decls even in Swift 4 mode
Dynamic does not imply @objc anymore.
2019-08-08 11:35:34 -07:00
David Ungar
e3d6e6b844 Merge pull request #26416 from davidungar/pbd-sourcerange
[ASTScope lookup] Fix PatternBindingEntry initializer getters and rectify its source range
2019-08-05 14:48:47 -07:00
David Ungar
b38076490b Address review comments re clarity
setOrigInit -> setOriginalInit
2019-08-05 13:42:35 -07:00
Nathan Hawes
5d47b45991 [IDE][Parse] Change the source location of TypeAttributes to point to the @ like DeclAttributes 2019-08-05 11:36:32 -07:00
David Ungar
1011998a97 Fix PatternBindingEntry::getSourceRange 2019-08-01 16:59:40 -07:00
Rintaro Ishizaki
1a211e6e5f Merge pull request #26403 from rintaro/gsoc-2019-part1
Reapply: [Parser] Decouple the parser from AST creation (part 1)
2019-08-01 18:41:11 +02:00
Slava Pestov
1ee2db4520 AST: Accessors no longer appear as members of their parent DeclContext
Accessors logically belong to their storage and can be synthesized
on the fly, so removing them from the members list eliminates one
source of mutability (but doesn't eliminate it; there are also
witnesses for derived conformances, and implicit constructors).

Since a few ASTWalker implementations break in non-trivial ways when
the traversal is changed to visit accessors as children of the storage
rather than peers, I hacked up the ASTWalker to optionally preserve
the old traversal order for now. This is ugly and needs to be cleaned up,
but I want to avoid breaking _too_ much with this commit.
2019-07-30 15:56:00 -04:00
Jan Svoboda
f0395a469a Revert "Revert "[Parser] Decouple the parser from AST creation (part 1)"" 2019-07-30 04:34:09 +00:00
David Ungar
d236a178ca Merge pull request #26095 from davidungar/parser-changes
[Parser] Fixes for ASTScope lookup
2019-07-29 19:59:00 -07:00
David Ungar
634a6eb718 Remove code for updating closure body. 2019-07-29 15:21:36 -07:00
David Ungar
30769127c8 Insert in order and other fix 2019-07-28 21:00:51 -07:00
Holly Borla
709efbc52c Sema: implement getInitKind using a request evaluator.
Add the request `InitKind` to lazily compute the kind of an initializer
declaration.
2019-07-26 15:55:09 -07:00
Holly Borla
58394eda5e Parse: check if constructor decls are marked as convenience rather than (indirectly) calling getInitKind
When we requestify `getInitKind`, we don't want to invoke the request during parsing. What the parsing code
really cares about is whether or not the decl has `ConvenienceAttr`.
2019-07-26 14:16:28 -07:00
David Ungar
9f60bb4c2f Adapt to streamlined record. 2019-07-25 08:44:02 -07:00
David Ungar
008791fc0a Ensure that an accessor can be found from its VarDecl. 2019-07-25 07:50:39 -07:00
David Ungar
691b3c6f30 When delayed parsing a Decl in a closure body, add it to the body. 2019-07-25 07:50:39 -07:00
David Ungar
6577e68b6b Fixes for review 2019-07-25 07:50:39 -07:00
David Ungar
3c7de8d707 Oops! Missed porting over the line to set the alias decl end. 2019-07-25 07:50:39 -07:00
David Ungar
79b9f6c68a Fix SubscriptDecl end position 2019-07-25 07:50:38 -07:00
David Ungar
8caf6f39e1 Fixes for ASTScope lookup
1. Track real EndLoc of TypeAliasDecl and SubscriptDecl.
2. Ensure TypeAliasDecl gets added to AST when doing completion.
2019-07-25 07:50:38 -07:00
Slava Pestov
3e45b327de Parse: Remove some bogus error recovery code for 'lazy' 2019-07-23 22:00:31 -04:00
Slava Pestov
8047ddae82 Sema: Move finishStorageImplInfo() to StorageImplInfoRequest evaluation
This merges Sema's special logic for updating the ImplInfo of lazy properties
and property wrappers with the StorageImplInfoRequest.

I had to move some code from the parser into the StorageImplInfoRequest, to
avoid request cycles caused by hasStorage() calls; this is the right thing to
do anyway.

Since hasStorage() now answers false for lazy properties and property wrappers,
we have to move some diagnostic checks from checkDeclAttributesEarly() to
the StorageImplInfoRequest implementation itself.

Over time, I expect all of the checks currently in checkDeclAttributesEarly()
and checkDeclAttributes() to either migrate to requests, or typeCheckDecl().
2019-07-23 22:00:31 -04:00
Slava Pestov
60e1dfe8b9 Sema: Use a request to compute AbstractStorageDecl::getImplInfo()
This just moves the code from the parser into a request. Sema will
still overwrite the ImplInfo field for lazy properties and
property wrappers; refactoring that is next.
2019-07-23 16:13:28 -04:00
Slava Pestov
bfe0ebb493 Parse: Split off StorageImplInfo computation from accessor parsing
Soon this will be performed lazily as part of a request.
2019-07-23 16:13:28 -04:00
Slava Pestov
56f8f05f95 AST: Move 'private set' attribute computation to SetterAccessLevelRequest 2019-07-23 16:13:28 -04:00
Slava Pestov
454281b226 AST: Split off StorageImplInfo from AbstractStorageDecl::AccessorRecord
We want to compute the former independently of the latter.
It's only 16 bits so storing it inside the Decl is fine;
it also allows us to eliminate the 'compact' representation
where an AbstractStorageDecl without an accessor record is
assumed to be stored.
2019-07-22 20:19:09 -04:00
Slava Pestov
a532a325e1 AST: Move a few methods from VarDecl down to ParamDecl 2019-07-22 20:19:09 -04:00
Doug Gregor
4820d16d7f [AST] Separate out the operations that set *parsed* bodies of functions.
When the parser wires up the body of a function, it's a legitimate use of
setting a parsed body. Separate these out from the other uses of
setBody() that we want to eliminate over time.
2019-07-12 14:08:38 -07:00
Brent Royal-Gordon
c66a8be4eb Revert "[Parser] Decouple the parser from AST creation (part 1)" 2019-07-09 14:07:43 -07:00
Argyrios Kyrtzidis
d0ddece7e2 Merge pull request #25193 from jansvoboda11/gsoc-2019-parser
[Parser] Decouple the parser from AST creation (part 1)
2019-07-08 13:49:40 -07:00
Sergej Jaskiewicz
0446ad3c3d Fix failing test cases for expected_keyword_in_decl diagnostic 2019-07-07 00:12:37 +03:00
Sergej Jaskiewicz
2b3ebf715a Use DescriptiveDeclKind for better expected_keyword_in_decl diagnostic 2019-07-06 00:57:26 +03:00
Sergej Jaskiewicz
924f15ef39 [Parse] Simplify missing_func_keyword diagnostic 2019-07-04 22:03:35 +03:00
Sergej Jaskiewicz
95eea2f3e9 [Parse] Implement "missing 'func' keyword" diagnostic with a fix-it
- When parsing a type or extension declaration, attempt to parse a function or property declaration when meeting an identifier, an operator or a paren (for tuple declarations).
- Produce the diagnostic with a fix-it suggesting to insert the needed keyword
- Recover parsing as if the declaration with the missing keyword is a function/property declaration

Resolves https://bugs.swift.org/browse/SR-10477
2019-07-04 20:06:35 +03:00
Jan Svoboda
44d7769238 [Parser] Decouple the parser from AST creation (part 1)
Instead of creating the AST directly in the parser (and libSyntax or
SwiftSyntax via SyntaxParsingContext), make Parser to explicitly create
a tree of ParsedSyntaxNodes. Their OpaqueSyntaxNodes can be either
libSyntax or SwiftSyntax. If AST is needed, it can be generated from the
libSyntax tree.
2019-06-28 14:28:19 +02:00
Doug Gregor
db5440bdef [SE-0258] Rename wrapperValue to projectedValue. 2019-06-26 07:39:01 -07:00
Doug Gregor
7bb01c743b [SE-0258] Promote projection variables ($foo) to the original property access
When the outermost property wrapper associated with a property has a
`wrapperValue`, create the projection property (with the `$` prefix)
at the same access level as the original property. This puts the
wrapped-value interface and the projection interface at the same level.

The newly-introduced @_projectionValueProperty attribute is implicitly
created to establish the link between the original property and the
projection value within module interfaces, where both properties will
be explicitly written out.
2019-06-26 07:39:01 -07:00
David Ungar
7c7c77c0ae Handle TopLevelCode case 2019-06-23 13:46:56 -07:00
Rintaro Ishizaki
bb3edd5dde [CodeCompletion] contextual attribute completion only on the same line
It's common to have decls on consecutive lines. Better to show too many
attributes than too few.
2019-06-21 14:03:09 -07:00
Rintaro Ishizaki
09ca68e485 [CodeCompletion] Don't attach attr to decl if blank line exists
```
@#^COMPLETE^#

public func something() {}
```
In this case, we can't say the user is adding attribute to the func or
starting a new declaration. So if there're one or more blank lines after the
completion, suggest context free attribute list.

rdar://problem/50441643
2019-06-20 17:06:32 -07:00
Slava Pestov
7913d30236 Sema: Use a request to compute FuncDecl::getSelfAccessKind() 2019-06-19 14:38:43 -04:00
Slava Pestov
25570d9f05 Merge pull request #25588 from slavapestov/remove-parser-implicit-accessors
Stop synthesizing accessors inside the parser
2019-06-19 14:12:13 -04:00
Rintaro Ishizaki
e52feac6d0 Merge pull request #25565 from owenv/unnamed_static_var_diag
[Diagnostics]: Fix broken diagnostic for unnamed static class property
2019-06-19 09:44:32 -07:00