Commit Graph

902 Commits

Author SHA1 Message Date
Brent Royal-Gordon
addbe3e5ed [NFC] Thread DeclNameRef through most of the compiler
This huge commit contains as many of the mechanical changes as possible.
2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
1df792ae9f [NFC] Convert TypeRepr to use DeclName(Loc)?
Replaces `ComponentIdentTypeRepr::getIdentifier()` and `getIdLoc()` with `getNameRef()` and `getNameLoc()`, which use `DeclName` and `DeclNameRef` respectively.
2019-12-11 00:45:08 -08:00
Brent Royal-Gordon
850583aceb [NFC] Extract Parser::parseUnqualifiedDeclBaseName 2019-12-11 00:45:07 -08:00
Brent Royal-Gordon
63ec1cf5af Introduce a separate #filePath, remove -pound-file
This makes the path behavior more first-class. The feature is now hidden behind an experimental flag, -enable-experimental-concise-pound-file.
2019-12-04 16:35:13 -08:00
Owen Voorhees
a3946cdb50 Revert "Revert "[Diagnostic] Improve diagnostic for trailing closures in statement conditions (#25165)""
This reverts commit e3a6b67c63.
2019-11-19 13:24:20 -08:00
Robert Widmann
dd1b15775d Partially Revert #27862
When SE-110 was being implemented, we accidentally began to accept
closure parameter declarations that had no associated parameter names,
e.g.

foo { ([Int]) in /**/ }

This syntax has never been sanctioned by any version of Swift and should
be banned.  However, the change was made long enough ago and there are
enough clients relying on this, that we cannot accept the source break
at the moment.  For now, add a bit to ParamDecl that marks a parameter
as destructured, and back out setting the invalid bit on the type repr
for these kinds of declarations.

To prevent further spread of this syntax, stub in a warning that offers
to insert an anonymous parameter.

Resolves part of rdar://56673657 and improves QoI for errors like
rdar://56911630
2019-11-10 22:10:53 -08:00
David Zarzycki
49276074fd [Parser] Track missing right brace correctly
Fixed compiler crasher 28651 now exits in milliseconds rather than seconds
because the constraint solver is no longer trying to solve a large
number of nested closures with missing right braces.
2019-11-05 15:27:14 +02:00
Robert Widmann
6dc3f4aad9 Fixup the destructuring diagnostics
Use the isInvalid() bit on the TypeRepr to signal that a closure
parameter is potentially a tuple destructure.  This has two benefits
1) Parse is no longer using the isInvalid() bit on Decl
2) Invalidating the type repr itself means that we no longer spuriously
diagnose variable patterns in destructures as missing types.
2019-10-24 16:03:41 -07:00
Nathan Hawes
05ef088859 Revert "Remove The Last Vestiges of isInvalid from Parse" 2019-10-22 11:31:07 -07:00
swift-ci
4edefa8e14 Merge pull request #27820 from CodaFi/valid-the-impaler 2019-10-21 16:35:00 -07:00
Robert Widmann
961a1cf0a4 Clean up invalidation in Parse
Clean up uses of setInvalid() and remove uses of isInvalid() in preparation for that being a semantic accessor.
2019-10-21 15:17:07 -07:00
Rintaro Ishizaki
7c43083718 [SyntaxParse] Sink element layout check to right before node creations
ParsedRawSyntaxRecorder::recordRawSyntax() and
ParsedRawSyntaxNode::makeDeferred()
2019-10-18 17:46:17 -07:00
Nathan Hawes
97757e4c2a [Parse] Assert that the children of syntax tree nodes have contiguous source ranges
This should help us catch syntax tree round-tripping issues.
2019-10-18 17:22:01 -07:00
Rintaro Ishizaki
aeec682c90 [SyntaxParse] Prevent memory leak in Syntax parsing
Essentially re-applying b09f87594a
2019-10-15 16:27:32 -07:00
Rintaro Ishizaki
8a03e08966 Revert "Merge pull request #26403 from rintaro/gsoc-2019-part1"
This reverts commit 1a211e6e5f, reversing
changes made to 482d0621a6.
2019-10-14 15:18:05 -07:00
Rintaro Ishizaki
570ed9361f Revert "Merge pull request #26883 from rintaro/revert-revert-26478-gsoc-2019-parser-types"
This reverts commit faaa3a859d, reversing
changes made to 62f947d6ba.
2019-10-14 15:18:05 -07:00
Rintaro Ishizaki
00613db8db Revert "Merge pull request #27230 from rintaro/syntaxparsse-rdar55421369"
This reverts commit b09f87594a, reversing
changes made to d0b7ecab00.
2019-10-14 12:47:23 -07:00
Rintaro Ishizaki
9fa176051d Revert "Merge pull request #27406 from nathawes/add-syntax-range-assertions"
This reverts commit 325204bd0d, reversing
changes made to 066bb61e8f.
2019-10-14 12:38:46 -07:00
Rintaro Ishizaki
4eadbaa9f6 Revert "Merge pull request #27466 from rintaro/syntaxparse-type"
This reverts commit a4fcd26b38, reversing
changes made to 88ecae4b9a.
2019-10-14 12:19:04 -07:00
Rintaro Ishizaki
e53ad15b10 Revert "Merge pull request #27508 from rintaro/syntaxparse-expridentifier"
This reverts commit dfe962f19a, reversing
changes made to 04ce7bf779.
2019-10-14 12:18:26 -07:00
Rintaro Ishizaki
2f40f2493b Revert "Merge pull request #27565 from rintaro/syntaxparse-exprcollection"
This reverts commit 1724f5b704, reversing
changes made to bc1a3eaaa5.
2019-10-14 12:16:31 -07:00
Rintaro Ishizaki
0e8010d8b9 Revert "Merge pull request #27592 from rintaro/syntaxparse-exprtuple"
This reverts commit cdfd1ab2cf, reversing
changes made to eb02f20f99.
2019-10-14 12:15:48 -07:00
Rintaro Ishizaki
b56c543f0d Revert "Merge pull request #27607 from rintaro/syntaxparse-exprunresolvedmember"
This reverts commit 5e1f790b3b, reversing
changes made to 1846a5957e.
2019-10-14 12:15:12 -07:00
Rintaro Ishizaki
572cfe26a9 Revert "[SyntaxParse] Parse ObjC keypath expression syntax"
This reverts commit 1036d2a2bf.
2019-10-14 12:11:40 -07:00
Robert Widmann
7770564f1a Merge pull request #27624 from CodaFi/in-locale-parentis
Downgrade The TypeLoc in VarDecl to a TypeRepr
2019-10-11 14:53:10 -07:00
Rintaro Ishizaki
1036d2a2bf [SyntaxParse] Parse ObjC keypath expression syntax 2019-10-11 11:55:22 -07:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
Rintaro Ishizaki
5e1f790b3b Merge pull request #27607 from rintaro/syntaxparse-exprunresolvedmember
[SyntaxParse] Parse object literal and unresolved member expressions
2019-10-11 18:59:10 +02:00
Slava Pestov
12231d2df3 Merge pull request #27571 from slavapestov/circular-validation-cleanups-5
Circular validation cleanups, part 5
2019-10-10 19:52:56 -04:00
Rintaro Ishizaki
6a9b2522a7 [SyntaxParse] Parse unresolved member expression syntax 2019-10-10 13:29:42 -07:00
Rintaro Ishizaki
f50966fcc1 [SyntaxParse] Parse ObjectLiteralExpr syntax 2019-10-10 13:22:57 -07:00
Slava Pestov
d8b61ff24b Sema: Peel off typeCheckParameterList()'s specifier computation into a request
Since getSpecifier() now kicks off a request instead of always
returning what was previously set, we can't pass a ParamSpecifier
to the ParamDecl constructor anymore. Instead, callers either
call setSpecifier() if the ParamDecl is synthesized, or they
rely on the request, which can compute the specifier in three
specific cases:

- Ordinary parsed parameters get their specifier from the TypeRepr.

- The 'self' parameter's specifier is based on the self access kind.

- Accessor parameters are either the 'newValue' parameter of a
  setter, or a cloned subscript parameter.

For closure parameters with inferred types, we still end up
calling setSpecifier() twice, once to set the initial defalut
value and a second time when applying the solution in the
case that we inferred an 'inout' specifier. In practice this
should not be a big problem because expression type checking
walks the AST in a pre-determined order anyway.
2019-10-10 15:00:07 -04:00
Rintaro Ishizaki
bb08667bf5 [SyntaxParse] Parse tuple/paren expression syntax 2019-10-09 14:48:47 -07:00
Rintaro Ishizaki
1de6819e34 [SyntaxParse] Parse Array/Dictionary literal syntax 2019-10-08 23:11:08 -07:00
Rintaro Ishizaki
242f9a7273 [SyntaxParse] parseExpressionSyntax()
(Implemented by Nathan Hawes @nathawes)
2019-10-08 23:11:08 -07:00
Rintaro Ishizaki
43df5a240e [SyntaxParse] Parse SuperRefExpr syntax 2019-10-08 22:15:02 -07:00
Rintaro Ishizaki
dfe962f19a Merge pull request #27508 from rintaro/syntaxparse-expridentifier
[SyntaxParse] Parse IdentifierExpr syntax
2019-10-08 19:17:46 +02:00
Rintaro Ishizaki
f42f60f233 [Syntax] Consolidate 'TupleElement' and 'FunctionCallArgument' kinds
into 'TupleExprElement'. They had exact the same layout.
2019-10-07 20:52:11 -07:00
Rintaro Ishizaki
597538ca18 [SyntaxParse] Parse IdentifierExpr syntax
Along with UnqualifiedDeclName (e.g. 'foo(x:y:)').
2019-10-02 17:06:51 -07:00
Rintaro Ishizaki
0264687b39 [SyntaxParse] Code styling 2019-10-01 15:41:40 -07:00
Nathan Hawes
f1a21348d2 [Parse] Assert that the children of syntax tree nodes have contiguous source ranges
This should help us catch syntax tree round-tripping issues.
2019-09-27 16:02:27 -07:00
Jordan Rose
8ff1dac381 [AST] Break some header dependencies for faster rebuilds (#27374)
DiagnosticEngine.h no longer depends on Attr.h.
Expr.h no longer depends on TypeRepr.h.

No functionality change.
2019-09-26 09:17:10 -07:00
Rintaro Ishizaki
b09f87594a Merge pull request #27230 from rintaro/syntaxparsse-rdar55421369
[SyntaxParse] Re-apply move-only ParsedRawSyntaxNode
2019-09-19 07:36:14 +02:00
Nathan Hawes
4dac0d1e8b Merge pull request #27218 from nathawes/r53958454-getFixedTypeRecursive-code-completion-crash
[code-completion] Remove special handling for completion on the RHS of an assignment
2019-09-18 10:49:38 -07:00
Nathan Hawes
54defbc7f7 [code-completion] Remove special handling for completion on the RHS of an assignment
This simplifies the code and prevents an assertion failure this code was
hitting computing the type relations between the result types and what it
determined as the expected type.

Resolves rdar://problem/53958454
2019-09-17 18:59:33 -07:00
Rintaro Ishizaki
9f642f0bc1 Revert "Merge pull request #27203 from CodaFi/movin-on-up"
This reverts commit 387d2a9aee, reversing
changes made to bf1ab6c29d.
2019-09-17 16:42:44 -07:00
Robert Widmann
d8aaf29617 Revert "Merge pull request #27132 from rintaro/syntaxparse-parsedrawsyntax-moveonly"
This reverts commit e675c4947d, reversing
changes made to 73315ba01e.
2019-09-16 15:10:33 -07:00
Rintaro Ishizaki
e675c4947d Merge pull request #27132 from rintaro/syntaxparse-parsedrawsyntax-moveonly
[SyntaxParse] Prevent memory leak in Syntax parsing
2019-09-14 01:06:15 +02:00
Rintaro Ishizaki
80085e0d27 [SyntaxParse] Make ParsedRawSyntaxNode move-only
So that we can easily detect 'ParsedSyntaxNode' leaking. When it's
moved, the original node become "null" node. In the destructor of
'ParsedSyntaxNode', assert the node is not "recorded" node.
2019-09-11 16:33:49 -07:00
Nathan Hawes
aa0305ee80 [Parse][IDE] Fix document structure request output for interpolated string literals
InterpolatedStringLiteralExpr has a TapExpr, which contains a BraceStmt
containing the builder CallExprs to the builder appendInterpolation /
appendStringLiteral methods used to construct the final string. This is all
implementation detail, but the BraceStmt wasn't marked implicit and had a valid
(but incorrect) SourceRange, so the document structure request treated it as
any other BraceStmt and made a structure node for it. The invalid range ended
up tripping an assertion in the document structure walker in swift-ide-test.

This patch corrects the BraceStmts produced by interpolated strings to be
marked implicit and have the correct range, and also updates ModelASTWalker to
skip over the internal details of interpolated strings when walking them (the
CallExprs were also being emitted).
2019-09-09 09:54:17 -07:00