Commit Graph

678 Commits

Author SHA1 Message Date
Chris Lattner
8d3f88735d Add parens to the few cases in the stdlib that lack them for function types. 2016-05-06 21:07:08 -07:00
Jorge Bernal
0a3f913b20 SE-0070: Make Optional Requirements Objective-C-only.
Optional protocol requirements now require an explicit @objc attribute.

Fixes SR-1395
2016-05-06 11:05:52 +02:00
Joe Pamer
3b4d98445e SE-0072: Fully eliminate implicit bridging conversions from Swift
Per Swift Evolution proposal SE-0072, these changes prevent the compiler from introducing implicit bridging conversions during type checking.
2016-05-05 19:36:33 -07:00
Jordan Rose
54e4b59c59 StdlibUnittest: Fix NSException catching (broken by SE-0054).
Previously, the callback for objc_setUncaughtExceptionHandler
took a parameter of type 'AnyObject!', which was implicitly
unwrapped at all uses inside the closure. When that became
'AnyObject?', we started getting an extra layer of Optional in
the printed output.

This reverts the tests to their pre-4d540c2a state.
2016-05-04 14:17:15 -07:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00
Chris Willmore
af0c7bd620 Initial implementation of SE-0054 "Abolish IUO Type" (#2322)
This is a squash of the following commits:

* [SE-0054] Import function pointer arg, return types, typedefs as optional

IUOs are only allowed on function decl arguments and return types, so
don't import typedefs or function pointer args or return types as IUO.

* [SE-0054] Only allow IUOs in function arg and result type.

When validating a TypeRepr, raise a diagnostic if an IUO is found
anywhere other thn the top level or as a function parameter or return
tpye.

* [SE-0054] Disable inference of IUOs by default

When considering a constraint of the form '$T1 is convertible to T!',
generate potential bindings 'T' and 'T?' for $T1, but not 'T!'. This
prevents variables without explicit type information from ending up with
IUO type. It also prevents implicit instantiation of functions and types
with IUO type arguments.

* [SE-0054] Remove the -disable-infer-iuos flag.

* Add nonnull annotations to ObjectiveCTests.h in benchmark suite.
2016-05-03 14:06:19 -07:00
Dmitri Gribenko
069efee426 stdlib: SE-0065: change UnsafeBufferPointer.Indices to CountableRange<Int>
CountableRange is cheaper than DefaultRandomAccessIndices.
2016-04-28 17:13:55 -07:00
Dmitri Gribenko
75d9d9118c stdlib: check associated types of LazyMap and LazyFilter 2016-04-28 12:05:03 -07:00
Dave Abrahams
9bee5d182f [stdlib] location/formLocation => index/formIndex 2016-04-26 17:46:16 -07:00
Dmitri Gribenko
fc9c1f6a61 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-26 10:20:31 -07:00
Max Moiseev
28060f0fdf [stdlib][swift-3-indexing-model] fixing tests for Linux 2016-04-25 16:24:25 -06:00
Nate Cook
03d0dfc237 Add comment for resilience-related default case 2016-04-25 16:13:55 -05:00
Dmitri Gribenko
8e886a3bdd stdlib: ranges: remove range protocols
The RangeProtocol was a very weak and fragile abstraction because it
didn't specify the interpretation of the endpoints.  To write a
non-trivial algorithm, one usually needed to consult that information.
The standard library code only actually worked correctly with half-open
and closed ranges (and didn't handle fully open ranges, for example).

The other two protocols, HalfOpenRangeProtocol and ClosedRangeProtocol,
were only used for code sharing, and present an ABI burden.  We can use
gyb instead.
2016-04-22 18:15:06 -07:00
Dave Abrahams
47a870cc50 [stdlib] Use location/formLocation for all index movement 2016-04-21 17:13:41 -07:00
Dmitri Gribenko
fc8d62dfbb Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-18 14:40:06 -07:00
practicalswift
db452dcbe9 [gardening] "[ a, b ]" → "[a, b]" 2016-04-17 21:26:08 +02:00
practicalswift
c2107f456c [gardening] "[ a, b ]" → "[a, b]" (#2227) 2016-04-17 21:02:18 +02:00
Chris Lattner
2acbb24e18 add some dead code back that Slava needs for his work on resilience. 2016-04-17 10:21:52 -07:00
Dmitri Gribenko
2b35fea059 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-16 00:30:12 -07:00
Chris Lattner
4fd8418ba7 move the stdlib to put noescape and autoclosure on the type, instead of
the parameter.  Progress towards SE-0049.
2016-04-14 23:13:43 -07:00
Dmitri Gribenko
cfea1a3f58 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-14 17:00:46 -07:00
Dmitri Gribenko
c52787e900 Merge commit '9cdbec13eee72feccfc5f8b987882a8c52e8107b' into swift-3-indexing-model 2016-04-14 16:23:53 -07:00
Dmitri Gribenko
3e708a9328 Merge commit '8e292daec1bc790c96b5ee39b8d55dadcac6ce1b' into swift-3-indexing-model 2016-04-14 15:10:26 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
practicalswift
dc6c2aeef6 [gardening] "Type->Type" → "Type -> Type" in Swift code 2016-04-13 23:03:55 +02:00
Dave Abrahams
1c3d998951 Revert "[gardening] "Type->Type" → "Type -> Type" in Swift code"
This reverts commit 14edeaf67a because
it's breaking tests:
https://ci.swift.org/job/oss-swift-incremental-RA-osx/lastFailedBuild/consoleFull#1361088108ee1a197b-acac-4b17-83cf-a53b95139a76
2016-04-13 10:29:57 -07:00
practicalswift
14edeaf67a [gardening] "Type->Type" → "Type -> Type" in Swift code 2016-04-13 10:51:53 +02:00
swift-ci
728d21a00d Merge pull request #1442 from SwiftAndroid/master 2016-04-12 23:30:17 -07:00
Chris Lattner
8f1dc858e8 remove dead code. 2016-04-12 21:07:28 -07:00
Zhuowei Zhang
7c502b6344 Port to Android
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.

Mailing list discussions:

1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html

The Android variant of Swift may be built using the following `build-script`
invocation:

```
$ utils/build-script \
  -R \                                           # Build in ReleaseAssert mode.
  --android \                                    # Build for Android.
  --android-ndk ~/android-ndk-r10e \             # Path to an Android NDK.
  --android-ndk-version 21 \
  --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
  --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
  --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
  --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
```

Android builds have the following dependencies, as can be seen in
the build script invocation:

1. An Android NDK of version 21 or greater, available to download
   here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
2016-04-12 19:26:21 -04:00
practicalswift
c760f6dfbf [gardening] Add whitespace: "foo,bar" → "foo, bar" 2016-04-12 22:31:46 +02:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Max Moiseev
0124bd261f [stdlib][swift-3-indexing-model] un-commenting and un-spliting .lazy usages 2016-04-11 17:58:52 -07:00
Jordan Rose
b911fda8ea [StdlibUnittest] Add expectNotEqual(expected: T?, actual: T?)
Also simplify the implementation of expectEqual(T?, T?).
2016-04-11 17:55:10 -07:00
Dmitri Gribenko
d52cbab5c2 Merge commit '0ff3239b962218267d37307e53906b31315a1cfc' into swift-3-indexing-model
This commit is the parent of the commit that implemented SE-0046
Establish consistent label behavior across all parameters including
first labels
2016-04-09 16:18:33 -07:00
Dmitri Gribenko
4efc16b5f1 StdlibUnittest: strengthen constraints in check*AssociatedTypes() 2016-04-08 18:46:00 -07:00
Harlan Haskins
5d888873da [StdlibUnittest] Teach interpreter to run crash tests 2016-04-08 13:12:53 -07:00
Max Moiseev
6c56af5c1b [stdlib] splitting expressions with lazy to improve compilation time 2016-04-08 11:06:05 -07:00
Harlan
e6395343cf Update autoreleasepool definition in RaceTest
Missed in SE-0046 migration
2016-04-07 13:54:02 -07:00
practicalswift
66183cdbf7 [gardening] Fix unjustified spacing 2016-04-07 10:10:24 +02:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Dave Abrahams
5864117b1b [stdlib] De-underscore Range.init(uncheckedBounds:) 2016-04-06 09:20:30 -07:00
Dave Abrahams
db03708a3d [stdlib] De-underscore Range protocols
There's really no excuse for keeping these hidden; they appear in public
APIs.
2016-04-05 16:32:15 -07:00
Dmitri Gribenko
0bab6fc461 StdlibUnittest: add a doc comment to LifetimeTracked, and remove a fixme 2016-04-05 15:39:30 -07:00
Slava Pestov
11cff083d8 StdlibUnittest: Add a default case to a switch over a resilient enum
I'm not completely satisfied with this fix because we get a compiler
warning when compiling without -enable-resilience. Perhaps we need
a policy change that a default case in a switch only generates a
warning if the enum is *explicitly* @_fixed_layout (or eventually,
@closed or however this attribute ends up being written).
2016-04-05 00:28:34 -07:00
Dmitri Gribenko
0a0825d18d Merge pull request #1972 from apple/StdlibUnittest-make-classes-final
StdlibUnittest: make TestSuite and other helper classes final
2016-04-04 15:10:46 -07:00
Dmitri Gribenko
6985b958fd Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-04 11:42:17 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Dmitri Gribenko
e43e25e3b7 StdlibUnittest: add optimized overloads for expectEqualsUnordered() 2016-04-01 23:05:19 -07:00
Dmitri Gribenko
bad2ff1bb7 StdlibUnittest: add assertions for range checks 2016-04-01 14:12:17 -07:00