Commit Graph

17 Commits

Author SHA1 Message Date
Max Moiseev
859db53d87 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-01 12:56:26 -08:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Max Moiseev
7c35559ad1 fixing tests 2016-01-20 17:21:51 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
Jason Choi
54a8520c4a Change () -> () to () -> Void in foreign_errors 2015-12-22 01:18:31 -08:00
Doug Gregor
06c5e9cd5b Enable "omit needless words" by default.
Most of this is in updating the standard library, SDK overlays, and
piles of test cases to use the new names. No surprises here, although
this shows us some potential heuristic tweaks.

There is one substantive compiler change that needs to be factored out
involving synthesizing calls to copyWithZone()/copy(zone:). Aside from
that, there are four failing tests:

    Swift :: ClangModules/objc_parse.swift
    Swift :: Interpreter/SDK/Foundation_test.swift
    Swift :: Interpreter/SDK/archiving_generic_swift_class.swift
    Swift :: Interpreter/SDK/objc_currying.swift

due to two independent remaining compiler bugs:
  * We're not getting partial ordering between NSCoder's
  encode(AnyObject, forKey: String) and NSKeyedArchiver's version of
  that method, and
  * Dynamic lookup (into AnyObject) doesn't know how to find the new
  names. We need the Swift name lookup tables enabled to address this.
2015-12-11 14:46:50 -08:00
John McCall
b75f5f2450 Type-check catch patterns in closures as necessary in order
to decide whether they're exhaustive.

Unfortunately, we can't actually just type-check the pattern
because it might be dependent on other local type-checking state,
like the types of arguments or variables defined within the closure.
So instead we try to recognize a very specific pattern shape that
should be safe to coerce.

Also, this potentially introduces redundant diagnostics because
of the double-check, but it's tricky to do anything about it.
I think it's better to have these potential redundancies than
to infer a throwing closure type with 'catch let e as NSError',
though.

rdar://21715350

Swift SVN r30701
2015-07-27 22:57:47 +00:00
John McCall
d190ee0767 Honor the swift_error attribute during import.
Add a new convention to describe what happens with
nonzero_result on a type that isn't imported as Bool.
This isn't really a safe convention to implement, but
calls are fine.

Implements <rdar://21715350>.

Swift SVN r29953
2015-07-08 00:57:27 +00:00
Jordan Rose
285ee60fd4 [ClangImporter] Generalize the hack from r29212 to cover any unavailable members.
If there is a method -foo: that's unavailable (for whatever reason), and we now
have a method -foo:error: that we'd like to import, it's okay to drop the error
parameter there. Overload resolution can handle filtering out the unavailable
method.

rdar://problem/21497221

Swift SVN r29746
2015-06-26 22:19:20 +00:00
Jordan Rose
c8c5c643bd [ClangImporter] Also strip "WithError" like we do "AndReturnError".
A few APIs in our frameworks use "WithError" instead, even though it's not
the recommended pattern.

rdar://problem/21212613

Swift SVN r29577
2015-06-23 20:39:53 +00:00
Joe Groff
bebfa969bd Sema: Allow 'x.init' references on metatype expressions.
If 'x.init' appears as a member reference other than 'self.init' or 'super.init' within an initializer, treat it as a regular static member lookup for 'init' members. This allows a more explicit syntax for dynamic initializations; 'self.someMetatype()' looks too much like it's invoking a method. It also allows for partial applications of initializers using 'someMetatype.init' (though this needs some SILGen fixes, coming up next). While we're in the neighborhood, do some other correctness and QoI fixes:

- Only lookup initializers as members of metatypes, not instances, and add a fixit (instead of crashing) to insert '.dynamicType' if the initializer is found on an instance.
- Make it so that constructing a class-constrained archetype type correctly requires a 'required' or protocol initializer.
- Warn on unused initializer results. This seems to me like just the right thing to do, but is also a small guard against the fact that 'self.init' is now valid in a static method, but produces a newly-constructed value instead of delegating initialization (and evaluating to void).

Swift SVN r29344
2015-06-08 04:11:28 +00:00
John McCall
98824498ba Flesh out the foreign-override testing a bit.
Swift SVN r28709
2015-05-18 18:14:07 +00:00
Slava Pestov
95dc298d3a ForeignErrorConvention ctor was not setting ErrorParameterIsReplaced correctly
For some reason this was only breaking with initializers, and not
ordinary methods, where there was both a throwing and non-throwing
version of the same method.

Fixes <rdar://problem/20922973>.

Swift SVN r28534
2015-05-13 21:42:35 +00:00
John McCall
9065880e5a When an error import would conflict with another method,
preserve the original method name.

This heuristic is based on the Objective-C selector and therefore
doesn't really handle factory methods that would conflict with
initializers, but we can hope that those simply don't come up in
the wild.

It's not clear that this is the best thing to do --- it tends to
promote the non-throwing API over what's probably a newer, throwing
API --- but it's significantly easier, and it unblocks code without
creating deployment problems.

Swift SVN r28066
2015-05-02 01:52:37 +00:00
John McCall
5a153b60d6 Remove the affirmative -import-error-handling option.
We may want to add a -no-import-error-handling option for
project staging, but there's no need for the positive form.

Swift SVN r28049
2015-05-01 20:41:41 +00:00
John McCall
26b3f386e0 Fix a bug with importing inherited factory methods with
foreign-error conventions.

Swift SVN r28003
2015-04-30 22:34:41 +00:00
John McCall
0c6e412116 Rename and reorganize some error-handling tests.
Swift SVN r27914
2015-04-29 17:28:52 +00:00