Commit Graph

4650 Commits

Author SHA1 Message Date
Jordan Rose
1f0d262425 SDK overlay: weak-link to frameworks introduced since our API sunset.
Apps don't weak-link our overlays today, so if the overlays strong-link
to frameworks apps won't launch on older OSs. This was causing failures
on the buildbot, but is actually a serious issue for our developers.

Swift SVN r31180
2015-08-12 18:30:13 +00:00
Joe Pamer
10afd159e4 Following up on r31169, take Jordan's CR feedback and uncomment the two currently disabled migration aid overloads for 'print'.
Swift SVN r31176
2015-08-12 18:10:35 +00:00
Joe Pamer
cd492d96b5 Fix a type checker crash when the object type of a ForceValueExpr is an 'Any'.
This allows us to remove the workaround generic overloads for "print" without sacrificing good diagnostics for its unavailable overloads. (rdar://problem/21499048, rdar://problem/21582758, rdar://problem/22126141)

Swift SVN r31169
2015-08-12 15:59:31 +00:00
Michael Gottesman
c6f96ea036 Sorry did not mean to commit this.
Swift SVN r31168
2015-08-12 05:31:51 +00:00
Michael Gottesman
8759b79d79 [arc] When checking if a BB is an ARC Inert Trap BB, first check if the end is unreachable before you do anything further.
This inefficient call took up 8-9% of the compile time of Global ARC Opts when
compiling a release no-assert stdlib with a release compiler with assertions.

NFC.

<rdar://problem/22244924>

Swift SVN r31167
2015-08-12 05:31:19 +00:00
Jordan Rose
ff7b6b74fe Foundation overlay: Add a generic NSCoder.decodeObjectOfClass(_:forKey:).
Like decodeTopLevelObjectOfClass(_:forKey:), this API works very nicely
as a generic method in Swift, and this one is actually the one we expect
to be commonly used. One thing to note here is that these methods are
stricter than their ObjC counterparts: they will do a forced checked cast
even when the unarchiver does not use "secure" coding.

This depends on the previous commit; without it, we do not actually
enforce type safety for these methods.

The API notes change is to make the non-generic version of this method
unavailable so that it does not participate in overload resolution.
Without this we prefer the non-generic method unless there's a contextual
type for the result. I've filed rdar://problem/22243198 to track taking
this out once Foundation has updated their headers.

rdar://problem/17060110 (again)

Swift SVN r31154
2015-08-12 01:36:08 +00:00
Dave Abrahams
880f28b3fd [stdlib] Add missing 10.10 NSString APIs.
containsString and localizedCaseInsensitiveContainsString were
introduced in 10.10, release-noted, but never
documented (<rdar://22236574>), so we missed them.

Fixes <rdar://18776075> String.containsString doesn't work in Swift

Swift SVN r31152
2015-08-12 00:37:43 +00:00
Slava Pestov
1628bfc3e2 SIL: Split dealloc_ref into [constructor] and [destructor] kinds
dealloc_ref [destructor] is the existing behavior. It expects the
reference count to have reached zero and the isDeallocating bit to
be set.

The new [constructor] variant first drops the initial strong
reference.

This allows DI to properly free uninitialized instances in
constructors. Previously this would fail with an assertion if the
runtime was built with debugging enabled.

Progress on <rdar://problem/21991742>.

Swift SVN r31142
2015-08-11 18:38:00 +00:00
Slava Pestov
89f2af6bb3 Random comment fixes split off from another patch, NFC
Swift SVN r31140
2015-08-11 18:37:52 +00:00
Chris Lattner
f2f16dea4c remove a patch accidentally committed with r31130
Swift SVN r31138
2015-08-11 18:28:15 +00:00
Chris Lattner
a899872d91 Reapply r31105, with some fixes to invalid unconstrained generics. These fixes correct
the regressions that r31105 introduced in the validation tests, as well as fixing a number
of other validation tests as well.

Introduce a new UnresolvedType to the type system, and have CSDiags start to use it
as a way to get more type information out of incorrect subexpressions.  UnresolvedType
generally just propagates around the type system like a type variable:
 - it magically conforms to all protocols
 - it CSGens as an unconstrained type variable.
 - it ASTPrints as _, just like a type variable.

The major difference is that UnresolvedType can be used outside the context of a
ConstraintSystem, which is useful for CSGen since it sets up several of them to 
diagnose subexpressions w.r.t. their types.

For now, our use of this is extremely limited: when a closureexpr has no contextual
type available and its parameters are invalid, we wipe them out with UnresolvedType
(instead of the previous nulltype dance) to get ambiguities later on.

We also introduce a new FreeTypeVariableBinding::UnresolvedType approach for
constraint solving (and use this only in one place in CSDiags so far, to resolve
the callee of a CallExpr) which solves a system and rewrites any leftover type 
variables as UnresolvedTypes.  This allows us to get more precise information out,
for example, diagnosing:

 func r22162441(lines: [String]) {
   lines.map { line in line.fooBar() }
 }

with: value of type 'String' has no member 'fooBar'
instead of: type of expression is ambiguous without more context

This improves a number of other diagnostics as well, but is just the infrastructural
stepping stone for greater things.





Swift SVN r31130
2015-08-11 06:06:05 +00:00
Arnold Schwaighofer
afe39b3c1a Allow hoisting of uniqueness check in array.append
At -O I see about 10% improvement on Havlak, and 40% improvement on the recently
added array append benchmarks.

COWTree regresses by 15% because we hoist an append that is conditionally
executed. If we were to disallow hoisting of conditionally executed benchmarks
we would see big loses accross our benchmarks (for example, we would not hoist
out of nested loops anymore). So we will have to live with this regression.

rdar://17140639

Swift SVN r31120
2015-08-10 20:40:20 +00:00
David Farler
d5e9bde7e7 Don't use private functions in the CG overlay
Use an internal underscore function instead.

Swift SVN r31094
2015-08-08 01:45:10 +00:00
David Farler
8b10d158d7 Fixit Typo: CGRect.integralRect -> integerRect
Swift SVN r31084
2015-08-07 20:52:37 +00:00
David Farler
9f10b691e6 Reviewed: Containers should use debug description of their elements in both description and debugDescription
- Don't need CollectionOfOne.description
- Don't use private functions for shared internal functions for
  constructing descriptions

Swift SVN r31071
2015-08-07 08:52:35 +00:00
David Farler
5091dc244d Really fix the Optional map/flatMap mismerge
Swift SVN r31070
2015-08-07 08:20:27 +00:00
David Farler
697d0dbd4f Build fix: mismerge in Optional.swift
Swift SVN r31069
2015-08-07 07:10:45 +00:00
David Farler
4848235c7f Rename Optional type parameter from 'T' to 'Wrapped'.
rdar://problem/21970065

Swift SVN r31068
2015-08-07 06:17:20 +00:00
David Farler
9aa7663ad3 Always debugPrint containers' elements
rdar://problem/19312992

Swift SVN r31067
2015-08-07 06:14:19 +00:00
Dmitri Hrybenko
050a2cdea8 Foundation overlay: adopt @warn_unused_result
Reviewed by Michael J LeHew Jr.

Swift SVN r31064
2015-08-06 23:50:53 +00:00
Dmitri Hrybenko
e587ef0086 SDK overlay: adopt @warn_unused_result
Swift SVN r31051
2015-08-06 15:54:52 +00:00
Dmitri Hrybenko
255d2229c7 stdlib: remove erroneous @warn_unused_result annotations
Swift SVN r31050
2015-08-06 15:54:47 +00:00
Dmitri Hrybenko
dd3194a18c stdlib: adopt @warn_unused_result
rdar://20957486

Swift SVN r31048
2015-08-06 14:53:18 +00:00
Mish Awadah
10bdef0936 Revert "CMake: build all platforms except watchOS using the public SDK"
This reverts commit cd3f1ba7d1ee2397817e1a165209fdeab8a1c004.

Reverting this b/c it is breaking buildbots with the following:
CMake Error at CMakeLists.txt:522 (message):
  CrashReporterClient library is required, but it was not found

Swift SVN r31047
2015-08-06 06:12:23 +00:00
Dmitri Hrybenko
271acdfcab CMake: build all platforms except watchOS using the public SDK
Covers rdar://problem/21145996.
A step towards rdar://problem/21099318.

Swift SVN r31041
2015-08-06 04:28:05 +00:00
Dave Abrahams
f59279dc31 [stdlib] Fix a couple of availability message
Swift SVN r31025
2015-08-05 20:02:34 +00:00
Dmitri Hrybenko
827224f146 stdlib: clarify the behavior of sequences and for loops
This is not a new rule, this is just a consequence (although a
non-trivial one) of existing rules.

Swift SVN r31024
2015-08-05 19:06:10 +00:00
Arnold Schwaighofer
e0d069a0e0 stdlib: Call _print_unlocked directly in String.init
Then we can get rid of the specialized print function.

Swift SVN r31022
2015-08-05 14:44:13 +00:00
Ben Langmuir
0fa6d7b65f Revert "Move GameKit overlay to GameCenter."
The headers went back to GameKit in a new SDK.

This reverts commit r30322.

Swift SVN r31015
2015-08-04 22:27:47 +00:00
Jordan Rose
54cca1a2fa Restore fully-general signature for IntervalType.overlaps.
rdar://problem/22085137

Swift SVN r31010
2015-08-04 21:57:03 +00:00
David Farler
8eec4b6e13 RangeReplaceable: document and enforce count >= n for removeFirst(n)
Swift SVN r31001
2015-08-04 19:41:14 +00:00
Arnold Schwaighofer
9c77c05696 stdlib: Call a private specialized version in String.init
The print abi changed so that there is no longer a way to print one item to a
stream without going through a vararg array. We call the print function in a
String initializer (e.g for string interpolation) incurring unnecessary
overhead. Use an internal specialized version of print instead.

rdar://22133281

Swift SVN r31000
2015-08-04 19:19:50 +00:00
Mish Awadah
61645429a0 [castle] Correct byte transfer logic for large transfers.
This commit addresses:
<rdar://problem/22121657> stdlib/Slice.swift.gyb test failing on swift_tools-RA_stdlib-RDA_test-ios_device since #1325

Swift SVN r30997
2015-08-04 17:57:13 +00:00
Arnold Schwaighofer
8c112d1fea stdlib: Always inline the _UnsafePartiallyInitializedContiguousArrayBuffer builder functions
For performance reasons.

This should now truly have recovered PrimeNum's performance at -O.

rdar://22126579

Swift SVN r30988
2015-08-04 07:49:40 +00:00
David Farler
313a4c93c6 Review: Index protocol extensions
- Add Strict/Defaulted Index types to StdlibUnittest
- Test whether a random access index calls its more efficient
  customization by tracking successor calls.
- Fix the RandomAccessIndex.advancedBy(n, limit:) API by de-underscoring
  the limit parameter
- Inline some internal transparent default implementations to their only
  call site
- Attach _RandomAccessAmbiguity type to RandomAccessIndex

rdar://problem/22085119

Swift SVN r30979
2015-08-04 03:13:14 +00:00
David Farler
8febbc1095 Suggest NSURL path methods instead of NSString
rdar://problem/22095657

Swift SVN r30978
2015-08-04 02:59:41 +00:00
Jordan Rose
03e3dc2e2d stdlib: Workaround for IntervalType.overlaps to avoid a SIL parser error.
The parse_stdlib tests choke on the constraints that were there previously,
so weaken the API to only work on intervals of the same type for now.

rdar://problem/22126470

Swift SVN r30977
2015-08-04 02:10:49 +00:00
Joe Pamer
828eb68e72 Commit DaveA's API changes to 'print', along with the compiler changes necessary to support them.
There's still work left to do. In terms of next steps, there's still rdar://problem/22126141, which covers removing the 'workaround' overloads for print (that prevent bogus overload resolution failures), as well as providing a decent diagnostic when users invoke print with 'appendNewline'.

Swift SVN r30976
2015-08-04 01:57:11 +00:00
Jordan Rose
c5bc10a597 stdlib: Update a comment I missed on Strideable.
Swift SVN r30975
2015-08-04 01:34:38 +00:00
Jordan Rose
83e2e0bbb2 Move the 'stride' family into methods on Strideable.
Part of the Protocol Extensions TLF.

rdar://problem/22085144

Swift SVN r30974
2015-08-04 01:32:41 +00:00
Jordan Rose
1ee08fe92a stdlib: Move 'overlaps' into a method on IntervalType.
Part of the Protocol Extensions TLF.

rdar://problem/22085137

Swift SVN r30973
2015-08-04 01:32:36 +00:00
David Farler
f8e418df74 Add renamed fixits for CG overlay API change rdar://problem/19788137
Swift SVN r30972
2015-08-04 01:16:11 +00:00
Jordan Rose
953424072e Guard "object literals" feature with SWIFT_ENABLE_OBJECT_LITERALS.
This is not a feature we're releasing at the moment, so provide a way
to turn it off.

rdar://problem/21935551

Swift SVN r30966
2015-08-04 00:16:52 +00:00
David Farler
cd947e397b Make CoreGraphics overlay naming consistent with the Standard Library
- Don't repeat type names in methods and properties
- Use 'InPlace' suffix for mutating variants of methods that return
  a CG type.

rdar://problem/19788137

Swift SVN r30960
2015-08-03 20:09:32 +00: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
Jordan Rose
a41c1fe7cb [stdlib] Don't try to swap an element with itself in 'partition'.
(or in 'randomShuffle')

This violates our inout aliasing rules, and can cause a crash in certain
situations.

To try to prevent this in the future I've added a debugPrecondition check
to 'swap' that checks addresses. This will only catch inout violations
where neither argument uses writeback, and might some day be optimized
away. Right now, though, it does seem to catch some simple violations
(though not the one in the Radar), so hopefully it will at least help keep
us from introducing new problems.

rdar://problem/21780567

Swift SVN r30956
2015-08-03 19:51:29 +00:00
Dmitri Hrybenko
9a77d843da stdlib: update references to 'isEmpty' in comments
Swift SVN r30954
2015-08-03 19:22:57 +00:00
Michael Gottesman
3fe541625c Do not copy a SliceBuffer when we have the full native buffer. Just return it.
Fixes the RangeAssignment regression. Reviewed by Dmitri.

<rdar://problem/22078500> RangeAssignment regressions in r30794

Swift SVN r30925
2015-08-02 04:42:53 +00:00
Dave Abrahams
ad43a596bd [stdlib] Retire the old lazy subsystem...
...replacing it with the new, after passing API review!

* The lazy free function has become a property.

* Before we could extend protocols, we lacked a means for value types to
  share implementations, and each new lazy algorithm had to be added to
  each of up to four types: LazySequence, LazyForwardCollection,
  LazyBidirectionalCollection, and LazyRandomAccessCollection. These
  generic adapters hid the usual algorithms by defining their own
  versions that returned new lazy generic adapters. Now users can extend
  just one of two protocols to do the same thing: LazySequenceType or
  LazyCollectionType.

* To avoid making the code duplication worse than it already was, the
  generic adapters mentioned above were used to add the lazy generic
  algorithms around simpler adapters such as MapSequence that just
  provided the basic requirements of SequenceType by applying a
  transformation to some base sequence, resulting in deeply nested
  generic types as shown here. Now, MapSequence is an instance of
  LazySequenceType (and is renamed LazyMapSequence), and thus transmits
  laziness to its algorithms automatically.

* Documentation comments have been rewritten.

* The .array property was retired

* various renamings

* A bunch of Gyb files were retired.

Swift SVN r30902
2015-08-01 03:52:13 +00:00
Dmitri Hrybenko
d7caf06551 stdlib: rename generic parameter of _SliceBuffer from T to Element
Swift SVN r30901
2015-08-01 03:27:07 +00:00