Commit Graph

2357 Commits

Author SHA1 Message Date
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
Joe Groff
5e1497967a Parse opaque types. 2019-04-17 14:43:32 -07:00
Robert Widmann
f6244302ef Merge pull request #24034 from kitasuke/remove_deprecated_decl_attributes_support
[Gardening] Remove deprecated decl attributes support
2019-04-16 11:19:41 -04:00
kitasuke
d35cbee083 Fix a comment for spell check of available 2019-04-16 12:19:36 +09:00
swift-ci
a2d932daaf Merge pull request #24050 from nkcsgexi/synthesize-r-brace 2019-04-15 18:50:08 -07:00
Xi Ge
746a88aec8 Syntax: synthesize right brace tokens if they are missing from nominal type decls. 2019-04-15 16:45:26 -07:00
kitasuke
543ddbceee Remove NSKeyedArchiver family support for decl attributes 2019-04-15 17:33:51 +09:00
Rintaro Ishizaki
9347328bfe Merge pull request #23961 from AnthonyLatsis/associativity-kind-coloring
Parse: Reinterpret associativity kinds as contextual keywords
2019-04-12 14:10:39 -07:00
fischertony
44dfba81e4 Parse: Reinterpret associativity kinds as contextual keywords 2019-04-11 21:27:39 +03:00
Brent Royal-Gordon
d9732a050f Allow the declaration of static subscripts
In this commit, MyStruct.self[0] parses and typechecks but the solution doesn’t apply correctly. MyStruct[0] gets diagnosed as an error.
2019-04-10 23:09:44 -07:00
Slava Pestov
003a9a47b2 Parse: Remove obsolete @autoclosure(escaping) and @noescape type attributes
Some diagnostics got worse, but I think the reduction in compiler complexity
is worth it, and copy-and-pasting Swift 2 code is not likely to produce great
results anyway.

Also, this corrects an oversight where we did not reject @pseudogeneric on
function types in AST parsing.
2019-04-09 15:02:14 -04:00