Commit Graph

13947 Commits

Author SHA1 Message Date
Michael Gottesman
1e7d7fb85f Revert "[stdlib] Array bridging specification tweaks"
This reverts commit r17408.

Swift SVN r17417
2014-05-05 04:05:36 +00:00
Doug Gregor
ecb7612797 Strict keyword arguments: handle trailing closures harder.
Cope with lvalue types, optionals.


Swift SVN r17416
2014-05-05 03:40:23 +00:00
Doug Gregor
545eb3be31 Strict keyword arguments: fix locator for conversions.
We were getting constraint application failures under
-strict-keyword-arguments due to the wrong locator getting passed
down.


Swift SVN r17415
2014-05-05 03:33:53 +00:00
Argyrios Kyrtzidis
42484084f2 [ASTPrinter] Add an option to always print the keyword argument and the parameter,
even if they are the same.

rdar://16799973

Swift SVN r17412
2014-05-05 00:52:06 +00:00
Argyrios Kyrtzidis
f514d8862e [ASTPrinter] Remove PrintOptions option that is a leftover.
Swift SVN r17411
2014-05-05 00:08:59 +00:00
Dmitri Hrybenko
5ccee15360 ReST unittests: remove an empty test array, it is causing a -Wzero-length-array
warning


Swift SVN r17409
2014-05-04 23:46:04 +00:00
Dave Abrahams
a86aecd6fe [stdlib] Array bridging specification tweaks
Chris suggested that we should lazily typecheck each element when an
NSArray is downcast to Array<T>.  That sounded like a good idea, and
along the way we decided to simplify the implementation and spec by not
bending over backwards to allow broken duck-typing to work for pure ObjC
classes.

Swift SVN r17408
2014-05-04 23:16:06 +00:00
Chris Lattner
502e663e23 inline parsePatternIdentifier into its only caller, and simplify the result.
Swift SVN r17407
2014-05-04 23:14:15 +00:00
Argyrios Kyrtzidis
caf5bc4a4a [IDE/CodeCompletion] Ignore the internal members of Optional, like getLogicValue() and getMirror().
These are not commonly used and cause noise and confusion when showing among the the members of the underlying type.

Swift SVN r17405
2014-05-04 21:45:12 +00:00
Doug Gregor
a039bd5a42 Keyword arguments: don't require keywords for trailing closures.
This implementation accepts more than it should, because we don't
reliably have enough information in the constraint solver to know
whether an argument is actually a trailing closure or not.

Swift SVN r17404
2014-05-04 21:38:44 +00:00
Argyrios Kyrtzidis
8f2b5a0458 [IDE/CodeCompletion] Remove the space before a BraceStmtWithCursor chunk, if we are going to ignore it then the space is noise.
Swift SVN r17401
2014-05-04 21:21:12 +00:00
Argyrios Kyrtzidis
ee289793b0 [IDE/CodeCompletion] CodeCompletionString::getFirstTextChunkIndex() should return the chunk index where
the symbol name begins.

rdar://16712635

Swift SVN r17400
2014-05-04 21:21:07 +00:00
Doug Gregor
eb7a9144a8 Bring keyword arguments to subscripts.
Subscript declarations were still encoding the names of index
variables in the subscript type, which unintentionally made them
keyword arguments. Bring subscript declarations into the modern day,
using compound names to encode the subscript argument names, which
provides consistency for the keyword-argument world
<rdar://problem/14462349>. Note that arguments in subscripts default
to not being keyword arguments, which seems like the right default.

We now get keyword arguments for subscripts, so one can overload
subscripts on the names of the indices, and distinguish at the call
site. Under -strict-keyword-arguments, we require strictness here as well.

The IRGen/IDE/SILGen test updates are because the mangling of common
subscripts changed from accidentally having keyword arguments to not
having keyword arguments.

Swift SVN r17393
2014-05-04 19:31:09 +00:00
Enrico Granata
88e841ce10 Mis-ordering of cases - thanks Joe!
Swift SVN r17391
2014-05-04 18:05:46 +00:00
Enrico Granata
cb53af1bd1 Add a View tag to the QuickLookObject enum
This tag is meant to trade in image data, but be explicit about the fact that this is a "screenshot" of a UI view rather than a plain ol' picture

Fixes the swift library part of rdar://16796532



Swift SVN r17390
2014-05-04 18:03:13 +00:00
Argyrios Kyrtzidis
a0fa68b072 [IDE/CodeCompletion] Expose the getFirstTextChunk() function via a CodeCompletionString method.
Swift SVN r17388
2014-05-04 17:30:07 +00:00
Argyrios Kyrtzidis
5f24181015 [IDE/CodeComplete] Create a separate chunk for the 'override' keyword.
Swift SVN r17387
2014-05-04 17:29:59 +00:00
Doug Gregor
340e94700d Keyword argument QoI: use typo correction to help match keyword arguments to parameters.
This replaces this poor positional correction:

t.swift:3:10: error: incorrect argument labels in call (have 'baz:wobble:', expected 'withFoo:bar:')
mismatch1(baz: 1, wobble: 2)
         ^~~~     ~~~~~~
          withFoo bar

with a much better one:

t.swift:3:10: error: incorrect argument labels in call (have 'baz:wobble:', expected 'bar:wibble:')
mismatch1(baz: 1, wobble: 2)
         ^~~~     ~~~~~~
          bar     wibble

Swift SVN r17385
2014-05-04 15:13:47 +00:00
Greg Parker
3353e15270 [runtime] Don't free() a static empty string.
iOS device's CrashReporterClient is currently a no-op that is 
incompatible with malloc/free usage.


Swift SVN r17375
2014-05-04 09:13:34 +00:00
Greg Parker
cb94a2be54 [runtime] Use asl_log() instead of asl_log_message() to log to system console.
asl_log_message() is not available on OS X 10.9.


Swift SVN r17373
2014-05-04 08:21:37 +00:00
Mark Lacey
07fedc728a Defer erasing instructions in unreachable blocks.
Instead of erasing instructions immediately, keep track of them until
we've found all the ones we'll erase, and then erase them.

It's not clear to me why the code was hitting an assert as it was
written, but this works around the problem.

Fixes <rdar://problem/16805316>.

Swift SVN r17372
2014-05-04 07:26:46 +00:00
Mark Lacey
03a22fcc77 Fix a small issue with simplifying unchecked_enum_data.
Only simplify (unchecked_enum_data (enum payload)) when they refer to
the same element.

This hits when I apply the patch in <rdar://problem/16805316> and fix
the bug that it exposed. I looked at a handful of hits in the stdlib and
they all seem to be cases where we constant fold a conditional
branch (but have not yet simplified the branch), and the now-unreachable
side has code that creates a nil optional and then attempts to unwrap
it.

Swift SVN r17371
2014-05-04 07:26:45 +00:00
Argyrios Kyrtzidis
1a7e6485f4 [IDE/CodeCompletion] For override completions, separate the introducer keywords like "override func" in
a new chunk kind, so that we can sort/filter based on the name of the function.

Swift SVN r17369
2014-05-04 07:20:57 +00:00
Doug Gregor
98a359bd38 Keyword argument QoI: diagnostic missing/extra arguments directly.
Swift SVN r17368
2014-05-04 06:21:49 +00:00
Chris Lattner
1262105e61 Start parsing capture lists in closure expressions. Still much work
to go.



Swift SVN r17367
2014-05-04 05:39:22 +00:00
Argyrios Kyrtzidis
7f2fa7f97e [IDE] Filter out attributes like @objc and @availability when code-completing overrides.
rdar://16766431

Swift SVN r17366
2014-05-04 05:19:11 +00:00
Chris Lattner
8f444a4a61 simplify some parsing logic by using Token::isIdentifierOrNone more,
and rearrange some closure parsing logic to tidy it up, NFC.


Swift SVN r17363
2014-05-04 04:42:53 +00:00
Chris Lattner
d83289cb49 the 'destructor' keyword got renamed to 'deinit' a long time ago, remove
parsing and fixit support for 'destructor'.


Swift SVN r17361
2014-05-04 04:28:25 +00:00
Chris Lattner
d3df74d7a9 rename test
Swift SVN r17360
2014-05-04 04:25:37 +00:00
Chris Lattner
bf666142b8 Finish <rdar://problem/16688592> Change "-> Self" syntax, and introduce a new "convenience" context sensitive keyword
This rejects the "-> Self" syntax and provides a fixit for the new syntax.


Swift SVN r17358
2014-05-04 04:09:42 +00:00
Chris Lattner
2427e36ff8 Introduce a new "convenience" context sensitive keyword, which can only be
used on init decls, with the same semantics as "-> Self".  Switch the ast
printer, and fixits to use it.

As driveby's, simplify verification of contextual keywords in declparsing,
and rename parseConstructor/Destructor to parseInit/Deinit.


Swift SVN r17356
2014-05-04 04:02:32 +00:00
Dave Abrahams
dd6b0f7144 [stdlib] More Array doc updates
There's little point in allowing Array<T> to have both direct and
indirect representations when T can be a class type.  Let's drop the
branch cost and generate less code.

Swift SVN r17353
2014-05-04 01:32:54 +00:00
Argyrios Kyrtzidis
bb66d6dd1a [IDE] Don't show '@transparent' in the module interface.
rdar://16804855

Swift SVN r17350
2014-05-04 01:24:55 +00:00
Argyrios Kyrtzidis
c0e69b8d4a [Printer] In PrintOptions, add a general 'exclude attributes' list for the attribute kinds we don't want to print.
Swift SVN r17349
2014-05-04 01:24:52 +00:00
Joe Pamer
c6448c3168 Update release notes.
Swift SVN r17346
2014-05-04 00:49:38 +00:00
Argyrios Kyrtzidis
9151996c9f [IDE] Don't show "import SwiftShims" in the stdlib interface.
Swift SVN r17344
2014-05-04 00:26:34 +00:00
Chris Lattner
86df649f90 Fix <rdar://problem/16797372> Bogus error: self.init called multiple times in initializer
DI has two paths for analyzing initialization state: one optimize for solving a single
fact (e.g. the state of a single non-tuple variable in a function), and one that handles 
the full generality of multiple states in parallel (e.g. a tuple in a function or the
fields of a struct/class during its init method).

Unfortunately, the dataflow analysis between these two implementations drifted, and I
fixed a bug in the "N" case (rdar://16119509 back in feb) that didn't get fixed in the "1"
case.  This reworks all of the dataflow to make the fact propagation more similar between
the two paths and fix the bug along the way.



Swift SVN r17343
2014-05-04 00:22:33 +00:00
Joe Pamer
62f9932795 Accept an Identifier instead of a StringRef in the new "could not find member" diagnostic.
Swift SVN r17342
2014-05-04 00:22:11 +00:00
Doug Gregor
4f7a3d40cf Start enforcing strict keyword argument usage and ordering under -strict-keyword-arguments.
Implement a completely new path for matching up an argument tuple to a
parameter tuple, which handles the specific rules we want for
calls. The rules are:

  - The keyword arguments at the call site must match those of the
    declaration; one cannot omit a keyword argument if the declaration
    requires it, nor can one provide a keyword argument if the
    declaration doesn't have one.
  - Arguments must be passed in order, except that arguments for
    parameters with defaults can be re-ordered among themselves (we
    can't test all of this because neither constraint application nor
    the AST can express these).

QoI is extremely important in this area, and this change improves the
situation considerably. We now provide good diagnostics for several
important cases, with Fix-Its to clean up the code:

  - Missing keyword arguments:

    t.swift:8:13: error: missing argument labels 'x:y:' in call
    allkeywords1(1, 2)
                ^
                 x: y:

  - Extraneous keyword arguments:

    t.swift:17:12: error: extraneous argument labels 'x:y:' in call
    nokeywords1(x: 1, y: 1)
               ^~~~   ~~~

  - General confusion over keyword arguments (some missing, some
    wrong, etc.):

    t.swift:26:14: error: incorrect argument labels in call (have
        'x:_:z:', expected '_:y:z:')
    somekeywords1(x: 1, 2, z: 3)
                 ^~~~
                        y:

There are still a few areas where the keyword-argument-related
diagnostics are awful, which correspond to FIXMEs in this
implementation:

  - Duplicated arguments: f(x: 1, x: 2)
  - Extraneous arguments: f(x: 1, y: 2, z: 3) where f takes only 2
    parameters
  - Missing arguments
  - Arguments that are out-of-order
  - Proper matching of arguments to parameters for diagnostics that
    complain about type errors.

And, of course, since this has only been lightly tested, there are
undoubtedly other issues lurking.

This new checking is somewhat disjoint from what constraint
application can handle, so we can type-check some things that will
then fail catastrophically at constraint application time. That work
is still to come, as is the AST work to actually represent everything
we intend to allow.

This is part of <rdar://problem/14462349>.

Swift SVN r17341
2014-05-03 23:58:09 +00:00
Chris Lattner
76523f775b move a note up, it didn't make the submission cutoff.
Swift SVN r17339
2014-05-03 23:15:43 +00:00
Argyrios Kyrtzidis
3bdd781956 [release-notes] Add new section.
Swift SVN r17338
2014-05-03 23:13:23 +00:00
Joe Pamer
96afbe7ae6 Remove "expression does not type-check".
Swift SVN r17337
2014-05-03 23:03:52 +00:00
Joe Pamer
ab576bb84b The constraint solver should try to diagnose all failures, rather than use a catch-all error message.
Swift SVN r17335
2014-05-03 23:03:50 +00:00
Joe Pamer
006158ff56 Always emit detailed type check diagnostics, update unit tests to reflect this.
Swift SVN r17334
2014-05-03 23:03:47 +00:00
Chris Lattner
a155fc642a minor "new" feature.
Swift SVN r17333
2014-05-03 22:51:28 +00:00
Ted Kremenek
3d248270ca Add prototype for KVO API overlay ("KVOContext") to NSObject, and provide test case.
This change adds a new variant of "addObserver:forKeyPath:options:context:"
that takes a "KVOContext" instead of an unsafe void*.  The variant
delegates to the original method, but first 'retain's the object
before turning it into an unsafe pointer.  The API is then matched
with a variant of 'removeObserver:forKeyPath:context:' which
delegates to the original method and then 'release's it.

This vision here is that Swift clients of this API will use this
variant, and not the unsafe one.  A refinement (later) is to
not expose the original methods at all, and provide a new method
'observeValueForKeyPath:ofObject:change:kvoContext:' that implements
a thunk that delegates to 'observeValueForKeyPath:ofObject:change:context:'
and does the void* cast (which the code in the test case does).

This needs to go through API review; names are strawman names.

Swift SVN r17325
2014-05-03 20:06:28 +00:00
Dave Abrahams
18d12fa234 [stdlib] One more note about Array casting
Swift SVN r17324
2014-05-03 19:51:52 +00:00
Dave Abrahams
5e045b4453 [stdlib] Limit array casts to Array<T>
There's no need to support up- or down-casts for NativeArray<T> or
Slice<T>.  Slice might turn out to be easy, but we don't have time right
now.  Doing it for NativeArray<T> would have efficiency costs that we
don't want to pay.

Swift SVN r17323
2014-05-03 19:49:53 +00:00
Joe Groff
3b4a9d2ba5 Add a 'conditionallyUnreachable' builtin.
This builtin only becomes unreachable when assert_configuration calls have been folded, allowing library-level checks to become unreachable based on the assert level.

Swift SVN r17322
2014-05-03 19:41:40 +00:00
Joe Groff
bf858cc8a1 SILGen: Handle inner pointer returns through currying and dynamic lookup.
When we partially apply an inner-pointer method or property, the thunk or partial_apply that applies "self" needs to be the one that handles lifetime-extending "self". Verify that a partial_apply-ed inner pointer method is not inner pointer and implement lifetime extension in the partial apply thunk. Fixes <rdar://problem/16803701>.

Swift SVN r17321
2014-05-03 18:37:42 +00:00