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
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
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
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
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
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
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
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
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
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
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
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
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
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