Commit Graph

34 Commits

Author SHA1 Message Date
Jordan Rose
e45dfe09c6 stdlib: Rename 'Native'/'Cocoa' representations inside Dictionary/Set.
...and then because of a compiler bug (SR-806), rename the helper
properties to 'asNative' and 'asCocoa'.

None of this is API, so there is no migration information.
2016-02-24 17:46:12 -08:00
Dmitri Gribenko
efaa39ea79 stdlib: add first argument labels and some other changes to conform to API guidelines 2016-02-15 23:47:54 -08:00
Dmitri Gribenko
9bcd5a1056 Collection.length => .count 2016-01-22 18:41:19 -08:00
Doug Gregor
1a38e0ad3b Merge branch 'master' into swift-3-api-guidelines 2016-01-06 15:32:55 -08:00
Doug Gregor
2091e7f852 Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-omit-needless-words 2015-12-18 10:54:46 -08:00
Dmitri Gribenko
73ce9ae7e9 Collection.count => .length
And other API changes that naturally fall out from this, like
Array(repeating:count:) => Array(repeating:length:).
2015-12-17 15:55:29 -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
David Farler
311baf73cf Index protocol extensions
- Remove free Swift functions for advance and distance and replace
  them with protocol extension methods:
  - advancedBy(n)
  - advancedBy(n, limit:)
  - distanceTo(end)
- Modernize the Index tests
  - Use StdlibUnittest
  - Test for custom implementation dispatch

Perf impact: No significant changes reported in the
Swift Performance Measurement Tool.

rdar://problem/22085119

Swift SVN r30958
2015-08-03 20:06:44 +00:00
Dmitri Hrybenko
f5de8757e4 stdlib: remove Word and UWord
These types are leftovers from the early pre-1.0 times when Int and UInt
were always 64-bit on all platforms.  They serve no useful purpose
today.  Int and UInt are defined to be word-sized and should be used
instead.

rdar://18693488

Swift SVN r30564
2015-07-24 05:01:32 +00:00
Joe Groff
a7b65aeea1 stdlib: Use shim functions to avoid name+type collisions with CoreFoundation functions.
Fixes rdar://problem/20981649.

Swift SVN r30426
2015-07-21 01:02:04 +00:00
Arnold Schwaighofer
f7771859d8 Rename the optimize_test feature to executable_test and document that feature.
Swift SVN r29213
2015-06-01 23:44:13 +00:00
Arnold Schwaighofer
3643c614a3 Run tests in optimize test modes
This runs all files that have a target-build-swift or target-run-stdlib-swift
RUN line in optimize test mode.

Swift SVN r29206
2015-06-01 21:23:31 +00:00
Arnold Schwaighofer
7ef38acb8d Disable test for optimized swift_test_mode until we have a fix
rdar://20981649

Swift SVN r28671
2015-05-17 02:02:37 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +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
Greg Parker
a190d015f8 [test] Fix two tests that didn't expect tagged pointer strings on iOS.
NewString.swift had an integer sign problem with MSB tagged pointers.
BridgeStorage.swift assumed iOS didn't supported tagged pointer strings yet.
rdar://20405604


Swift SVN r26922
2015-04-03 01:40:52 +00:00
Doug Gregor
6bd99d6660 Disable tests failing on the x86-64 simulator.
Tracked by rdar://problem/20405604.

Swift SVN r26896
2015-04-02 20:52:28 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Chris Lattner
3357ee21f3 Revert r25417, r25408, and r25370. This adds back back the warning for
un-type-annotated AnyObject binding in "if let", and allows general 
patterns in if-let.

This also reverts some unrelated QoI improvements that went in with those
patches, but I'll add those back next.


Swift SVN r25507
2015-02-24 18:55:54 +00:00
Chris Lattner
079173ce5b Dial back the warning about "type inferred to AnyObject may be unexpected" in an if/let
conditional context.  There is no point diagnosing it here (just like a foreach loop) because
the if/let is just unwrapping the optional in the initializer expression.

Removing this requirement eliminates a bunch of extraneous type annotations in the testsuite.



Swift SVN r25370
2015-02-18 06:13:11 +00:00
Graham Batty
83b4384fac Update test flags for linux failures and support.
Also removed the sdk 'feature' in favour of the more specific
objc_interop.

Swift SVN r24856
2015-01-30 21:31:48 +00:00
Dave Abrahams
0473b79c28 [stdlib] Let Cocoa slice its own strings
Creating _NSOpaqueString offered dubious benefits, especially in the
presence of tagged pointer strings.

Swift SVN r24612
2015-01-21 21:32:12 +00:00
Chris Willmore
68dd563fbf <rdar://problem/18311362> TLF: Eliminate implicit bridging conversions
Require 'as' when converting from Objective-C type to native type (but
continue to allow implicit conversion from native to Objective-C). This
conversion constraint is called ExplicitConversion; all implicit
conversions are covered by the existing Conversion constraint. Update
standard library and tests to match.

Swift SVN r24496
2015-01-18 00:07:45 +00:00
Dave Abrahams
8618e475ff [stdlib] String view tests now use StdlibUnittest
This approach is considered more modern, reliable, and debuggable than
using FileCheck.

Swift SVN r24064
2014-12-21 00:10:03 +00:00
Dave Abrahams
53964a44c4 [stdlib] Cleaning and commenting
Swift SVN r24017
2014-12-18 20:47:41 +00:00
Dave Abrahams
4d71e0874e [stdlib] Remove testing inefficiency
Bring some N^3-ness back down to N^2 in this test.

Swift SVN r24016
2014-12-18 20:47:40 +00:00
Dave Abrahams
5641c69283 [stdlib] More UTF16 index conversion testing
Swift SVN r24015
2014-12-18 20:47:39 +00:00
Dave Abrahams
05c230912d [stdlib] Some UTF16 index conversion testing
Swift SVN r24014
2014-12-18 20:47:39 +00:00
Dave Abrahams
386146364b [stdlib] Refactor String.UTF8Index for conversion
The old design did not strictly keep track of the index in underlying
UTF16, which would have made converting between the different index
types too difficult.  It also made equality comparison between indices
broken, because

  UTF8Index(s.utf16.startIndex+1, within: s.utf8)

and

  UTF8Index(s.utf16.startIndex, within: s.utf8).successor()

would often have completely different UTF8 buffers and offsets within
the underlying UTF16.

For some reason this disturbed SILPasses/devirt_default_case.swift,
which is now XFAIL'd.  <rdar://problem/19298212>
SILPasses/devirt_default_case.swift is XFAIL'd

Swift SVN r24012
2014-12-18 20:47:37 +00:00
Dave Abrahams
3c9c3fa457 [stdlib] conversions to String.UTF8Index
Swift SVN r24011
2014-12-18 20:47:35 +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
Maxwell Swadling
55f3289054 Added additional tests and comments to String
Swift SVN r23490
2014-11-20 22:33:13 +00:00
Jordan Rose
e83c117c30 [test] Hack: run stdlib tests first to start long-running tests earlier.
This decreases total testing time by over a minute on my old Mac Pro.
It probably has much less effect on systems with fewer cores, but shouldn't
be any worse there.

Swift SVN r22745
2014-10-15 01:30:51 +00:00