Commit Graph

33 Commits

Author SHA1 Message Date
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
David Farler
a759ca9141 Disallow 'var' bindings in case patterns
Make the following illegal:

switch thing {
  case .A(var x):
    modify(x0
}

And provide a replacement 'var' -> 'let' fix-it.

rdar://problem/23172698

Swift SVN r32883
2015-10-25 18:53:02 +00:00
Xi Ge
682e4320d8 [SyntaxModel] Adjust the end loc when converting from SourceRange to CharSourceRange. rdar://22676599
Swift SVN r32013
2015-09-16 21:58:53 +00:00
Xi Ge
a21010e8f7 [SyntaxColor] Teach syntax model walker not to walk into active regions inside #if config stmt twice. rdar://22224993
Swift SVN r31433
2015-08-24 18:28:08 +00:00
Jordan Rose
953424072e Guard "object literals" feature with SWIFT_ENABLE_OBJECT_LITERALS.
This is not a feature we're releasing at the moment, so provide a way
to turn it off.

rdar://problem/21935551

Swift SVN r30966
2015-08-04 00:16:52 +00:00
Chris Lattner
b075f810ba Reimplement error recovery in C-style for statement, where we'd turn a ClosureExpr
into the body of the for statement.  Instead of ripping the body of the closureexpr
out and putting it into the C Style for, wrap up the closureExpr into a call.  This
avoids breaking AST invariants because the ClosureExpr will be the DeclContext for
anything inside of it.

This fixes <rdar://problem/21679557> compiler crashes on "for{{"
... which was Practical Swift's shortest crasher.



Swift SVN r29916
2015-07-06 06:19:30 +00:00
Xi Ge
29cebb8ac5 [SyntaxModel] Ensure syntax-coloring does not crash when the last token is a DeclAttribute.
This may happen to rethrows, rdar://21324493

Swift SVN r29472
2015-06-17 23:35:58 +00:00
Ted Kremenek
02041a9e6f Revert "Revert "fix <rdar://problem/20883210> QoI: Following a "let" condition with boolean condition spouts nonsensical errors""
I thought this was the culprit behind the SourceKit test failure, but I was wrong.

Swift SVN r28621
2015-05-15 07:05:55 +00:00
Argyrios Kyrtzidis
7c69b077c7 [IDE] Add enum elements in the document structure.
rdar://18845613

Swift SVN r28618
2015-05-15 06:56:22 +00:00
Ted Kremenek
3ab75178de Revert "fix <rdar://problem/20883210> QoI: Following a "let" condition with boolean condition spouts nonsensical errors"
This is causing a regression with 'while ... where', and manifests in the SourceKit tests.

Swift SVN r28616
2015-05-15 06:50:10 +00:00
Chris Lattner
e6344e4ad6 fix <rdar://problem/20883210> QoI: Following a "let" condition with boolean condition spouts nonsensical errors
Swift SVN r28596
2015-05-15 01:14:20 +00:00
Greg Parker
847e321138 [test] Undo Linux XFAILs.
These failures either are intermittent or were fixed just before 
they were disabled.


Swift SVN r28548
2015-05-14 00:50:39 +00:00
Greg Parker
94958e14f3 [test] XFAIL two tests on Linux because swift-ide-test is crashing.
rdar://20946478


Swift SVN r28542
2015-05-13 23:47:41 +00:00
Maxwell Swadling
d239d4434f Added IDE support for Object Literals Expressions
Fixes rdar://problem/20839100
Object Literal Expressions now show up in the Document structure.

Swift SVN r28332
2015-05-08 23:22:09 +00:00
Chris Lattner
31c01eab73 Change the meaning of "if let x = foo()" back to Xcode 6.4 semantics. The compiler
includes a number of QoI things to help people write the correct code.  I will commit
the testcase for it as the next patch.

The bulk of this patch is moving the stdlib, testsuite and validation testsuite to
the new syntax.  I moved a few uses of "as" patterns back to as? expressions in the 
stdlib as well.



Swift SVN r27959
2015-04-30 04:38:13 +00:00
Chris Willmore
c7c7388cf2 Change do-while to repeat-while.
Change all uses of "do { ... } while <cond>" to use "repeat" instead.
Rename DoWhileStmt to RepeatWhileStmt. Add diagnostic suggesting change
of 'do' to 'repeat' if a condition is found afterwards.

<rdar://problem/20336424> rename do/while loops to repeat/while & introduce "repeat <count> {}" loops

Swift SVN r27650
2015-04-23 22:48:31 +00:00
Argyrios Kyrtzidis
7c5f1e8c1d [IDE] Make sure we don't leave structure nodes without pop'ing them.
rdar://20457518

Swift SVN r27119
2015-04-08 05:03:08 +00:00
Chris Lattner
59c22383fb Rework PatternBindingDecl to maintain a list of pattern/initexpr pairs inside of it.
Previously, a multi-pattern var/let decl like:
  var x = 4, y = 17

would produce two pattern binding decls (one for x=4 one for y=17).  This is convenient
in some ways, but is bad for source reproducibility from the ASTs (see, e.g. the improvements
in test/IDE/structure.swift and test/decl/inherit/initializer.swift).

The hardest part of this change was to get parseDeclVar to set up the AST in a way
compatible with our existing assumptions. I ended up with an approach that forms PBDs in 
more erroneous cases than before.  One downside of this is that we now produce a spurious
  "type annotation missing in pattern"
diagnostic in some cases.  I'll take care of that in a follow-on patch.





Swift SVN r26224
2015-03-17 16:14:18 +00:00
Argyrios Kyrtzidis
7ef96904f3 [test] Integrate 'test/IDE/structure_placeholders.swift' into 'test/IDE/structure.swift' and remove the extra test file. NFC.
Swift SVN r26216
2015-03-17 01:53:03 +00:00
Argyrios Kyrtzidis
f55a15066e [IDE] Avoid adding ErrorExprs to the document structure model.
Swift SVN r25895
2015-03-09 23:02:54 +00:00
Argyrios Kyrtzidis
da2e6ad04a [IDE] Add array/dictionary literals in the document structure.
rdar:/19999295

Swift SVN r25874
2015-03-09 01:30:39 +00:00
Argyrios Kyrtzidis
8d4b0ed470 [IDE] Include control-flow statements in the syntax structure model.
rdar://19988592

Swift SVN r25868
2015-03-09 00:42:42 +00:00
Argyrios Kyrtzidis
865719c2b8 [IDE] Introduce SyntaxStructureElements which will provide more info about a syntactic structure.
Swift SVN r25866
2015-03-09 00:42:39 +00:00
Argyrios Kyrtzidis
f8e5b6b3e2 [IDE] Modify structure testing to tag the relevant ranges directly on the source,
instead of outputting the info with lines/columns.

This make the structure more clear and testing more convenient.

Swift SVN r25865
2015-03-09 00:42:38 +00:00
Argyrios Kyrtzidis
c41569c7a7 [IDE] Enhance SyntaxStructureKind with global/static/class variable nodes.
Swift SVN r24497
2015-01-18 03:47:26 +00:00
Graham Batty
83f27a8af7 Revert "Mark tests that don't pass on linux as XFAIL."
This reverts commit 2711ca86de7bf6a7885ccea24219a48a590b1e95.

Swift SVN r23577
2014-11-24 17:42:13 +00:00
Graham Batty
198402dcfe Mark tests that don't pass on linux as XFAIL.
Swift SVN r23573
2014-11-24 17:40:37 +00:00
Sonny Falk
6b053e6252 [IDE] Add support for Swift extension declarations to the document substructure.
Add tests for struct, protocol and extension.
This addresses the first part of <rdar://problem/15818966>.

Swift SVN r19766
2014-07-10 00:23:00 +00:00
Sonny Falk
75d06575b6 [IDE] Pass the correct range in the document structure for keyword arguments
with parameters that have both API and local name.
Add a test for the above.
This addresses <rdar://problem/16905994>.

Swift SVN r18053
2014-05-14 01:51:06 +00:00
Argyrios Kyrtzidis
2d1f1b1386 Fix ConstructorDecl::getSourceRange() to return the signature range if there is no body, not the range of its containing type declaration.
Swift SVN r18046
2014-05-14 00:41:12 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Sonny Falk
ff0a037ae6 [IDE] Add initial document structure annotation support.
Swift SVN r9597
2013-10-22 20:54:46 +00:00