Commit Graph

2017 Commits

Author SHA1 Message Date
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
Slava Pestov
ea84da3fad Parse: Stop synthesizing implicit getters and setters
Sema is now capable of synthesizing accessors for local properties,
and SILGen can emit them, so we can remove this codepath altogether.
2019-06-18 18:38:38 -04:00
Owen Voorhees
89d4e6378d [Diagnostics]: Fix broken diagnostic for unnamed static class property 2019-06-16 19:35:17 -07:00
Doug Gregor
2e8d9a4331 [SE-0258] Adopt @propertyWrapper everywhere. 2019-06-12 13:09:40 -07:00
Rintaro Ishizaki
04ca9752cf [CodeCompletion] Enable type name completion for param decl attribute
rdar://problem/50074177
2019-06-11 17:34:45 -07:00
Rintaro Ishizaki
b31c142efb [CodeCompletion] Implement completion at custom attribute argument 2019-06-11 17:34:44 -07:00
Rintaro Ishizaki
62193c961e [CodeCompletion] Enable type completion at beginning of attribute
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
2019-06-11 17:34:44 -07:00
Rintaro Ishizaki
9ba232d718 [CodeCompletion] Implement completion at custom attribute argument 2019-05-31 11:09:54 -07:00
Rintaro Ishizaki
878c9c600b [CodeCompletion] Enable type completion at beginning of attribute
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
2019-05-31 09:44:19 -07:00
Nate Chandler
1267f659c6 Address PR comments on return omission. 2019-05-07 14:20:21 -07:00
Xi Ge
24f5ba741a Syntax: add Syntax support for property delegate attributes
rdar://50056605
2019-05-02 09:50:40 -07:00
Ben Langmuir
81ce653bc3 Merge pull request #23587 from benlangmuir/cc-omit-return
[code-completion] Add type context for single-expression function bodies
2019-04-25 13:49:45 -07:00
nate-chandler
155a155000 Merge pull request #23251 from nate-chandler/nate/omit-return
Allow return to be omitted from single expression functions.
2019-04-25 08:36:34 -07:00
Nate Chandler
f8ef213475 Corrected off-by-one error. 2019-04-24 10:09:19 -07:00
Nate Chandler
a09a9640d0 Don't implicitly return assignments.
Corrected a number of diagnostic regressions.
2019-04-24 10:09:19 -07:00
Nate Chandler
0b528ae9f5 Don't add an implicit () after return for initializers. 2019-04-24 10:04:20 -07:00
Nate Chandler
ac7a76c02d Don't insert return during code completion. 2019-04-24 09:59:53 -07:00
Nate Chandler
08bbce336f Addressed issues from PR review.
- preferred dyn_cast to is and get
- restored insertion of () on bare return statements
- used dyn_cast not dyn_cast_or_null when the argument is non-null
- used getSingleExpressionBody accessor during second AST modification
- eliminated erroneous access through null reference
2019-04-24 09:59:53 -07:00
Nate Chandler
74b462b3ba WIP: Allow return to be omitted from single expression functions. 2019-04-24 09:59:53 -07:00
Doug Gregor
56d450b595 [Property delegates] Contextualize direct initializers of custom attributes
When a custom attribute is given a direct initializer, save and re-use
the initializer context we create so that it can be associated with the
enclosing pattern binding. Fixes assertions involving explicit closures
in property delegates.
2019-04-23 11:32:29 -07:00
Doug Gregor
32b0245187 [Parser] Consistently use consumeIdentifier() for normal identifiers.
consumeIdentifier() provides the general way in which we consume an
identifier token and fill in an Identifier. Use it consistently in the
parser.
2019-04-23 11:31:58 -07:00
Doug Gregor
9c62420809 [AST] Generalize PatternBindingEntry's "Lazy" flag to "Subsumed"
The initializer associated with a lazy property should not be executed
directly, because it is subsumed by code synthesized into the
getter. Generalize the terminology here so we can re-use this path for
property delegate initialization.
2019-04-23 11:31:58 -07:00
Rintaro Ishizaki
7078862921 [CodeCompletion] Provide 'some' keyword where applicable
rdar://problem/49353647
2019-04-19 17:11:16 -07:00
Joe Groff
dbd3a48afb Track var/subscript opaque return decls for type reconstruction. 2019-04-17 14:46:22 -07:00
Joe Groff
399332b75b Parsable interface and type reconstruction support for opaque types.
When printing a swiftinterface, represent opaque result types using an attribute that refers to
the mangled name of the defining decl for the opaque type. To turn this back into a reference
to the right decl's implicit OpaqueTypeDecl, use type reconstruction. Since type reconstruction
doesn't normally concern itself with non-type decls, set up a lookup table in SourceFiles and
ModuleFiles to let us handle the mapping from mangled name to opaque type decl in type
reconstruction.

(Since we're invoking type reconstruction during type checking, when the module hasn't yet been
fully validated, we need to plumb a LazyResolver into the ASTBuilder in an unsightly way. Maybe
there's a better way to do this... Longer term, at least, this surface design gives space for
doing things more the right way--a more request-ified decl validator ought to be able to naturally
lazily service this request without the LazyResolver reference, and if type reconstruction in
the future learns how to reconstruct non-type decls, then the lookup tables can go away.)
2019-04-17 14:46:22 -07:00
Joe Groff
be0140fe56 Switch __opaque to some, per the latest rev of the proposal 2019-04-17 14:46:21 -07:00