Commit Graph

2015 Commits

Author SHA1 Message Date
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Ben Cohen
fefc2e40df Migrate _copyContents to be called from UnsafeMutableBufferPointer with checks for overrun. 2017-01-05 11:59:49 -08:00
ben-cohen
ce0d713cd6 fixed where clauses, Optional-as-Any and unused vars 2016-12-29 07:58:12 -08:00
Doug Gregor
255fdb1d61 Fix some bogus bridging casts that were allowed in Swift 3.
Swift 3 unintentionally allowed collection casts from, e.g.,
Set<AnyHashable> to Set<NSObject>, when in fact the object
representation of the AnyHashable might not be an NSObject. Fix up our
tests and overlays that ran afoul of this rule.
2016-12-21 13:46:13 -08:00
Nate Cook
7303125b7b [stdlib] Add tests for _sort3 function 2016-12-21 13:19:47 -06:00
Max Moiseev
61b923f396 Using init(extendingOrTruncating:) instead of a deprecated init(truncatingBitPattern:) 2016-12-15 14:53:31 -08:00
Max Moiseev
356c15cb4a Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-12-06 10:35:27 -08:00
Bob Wilson
b33d4fc84c Revert "Disable validation-test/stdlib/UnicodeLongTest.swift for watchos."
This reverts commit 231fb5e054.

This test was failing the last time we updated the stable branches
of LLVM/Clang so it was disabled. No one remembers what was the
problem, so try reenabling it to see if anything breaks.
2016-11-30 16:07:17 -08:00
Max Moiseev
70b2343626 Merge branch 'master' into new-integer-protocols 2016-11-28 15:25:01 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Jordan Rose
a286af7683 Re-enable long-disabled XCTest test. 2016-11-17 17:08:25 -08:00
Max Moiseev
953d919a22 Merge branch 'master' into new-integer-protocols 2016-11-16 14:46:31 -08:00
Chris Williams
d5a67319da Failable initializer Tests for Int->Float 2016-11-14 17:04:49 -08:00
Jordan Rose
88a4fbbbd7 [test] Update existing tests for array parameters with nullability.
No functionality change. These parameters were IUOs before; now
they're (correctly) true optionals.
2016-11-14 13:15:17 -08:00
Max Moiseev
92813be403 Merge branch 'master' into new-integer-protocols 2016-11-11 16:14:57 -08:00
Ben Cohen
e381287499 move unit test to more appropriate class 2016-11-09 12:29:12 -08:00
Doug Gregor
f168e7270c [Type checker] Use DependentMemberType instead of type variables for nested types.
In the constraint solver, we've traditionally modeled nested type via
a "type member" constraint of the form

  $T1 = $T0.NameOfTypeMember

and treated $T1 as a type variable. While the solver did generally try
to avoid attempting bindings for $T1 (it would wait until $T0 was
bound, which solves the constraint), on occasion we would get weird
behavior because the solver did try to bind the type
variable.

With this commit, model nested types via DependentMemberType, the same
way we handle (e.g.) the nested type of a generic type parameter. This
solution maintains more information (e.g., we know specifically which
associated type we're referring to), fits in better with the type
system (we know how to deal with dependent members throughout the type
checker, AST, and so on), and is easier to reason able.

This change is a performance optimization for the type checker for a
few reasons. First, it reduces the number of type variables we need to
deal with significantly (we create half as many type variables while
type checking the standard library), and the solver scales poorly with
the number of type variables because it visits all of the
as-yet-unbound type variables at each solving step. Second, it
eliminates a number of redundant by-name lookups in cases where we
already know which associated type we want.

Overall, this change provides a 25% speedup when type-checking the
standard library.
2016-11-05 23:20:28 -07:00
practicalswift
4552fc8f88 [gardening] Use American English: "behaviour" → "behavior" 2016-11-05 20:33:57 +01:00
Alexis Beingessner
8b44a07f58 remove nonsensical identity tests from test suite
The test was verifying that two independently constructed
empty cocoa sets somehow had the same identity. Not sure why this used
to hold, but it's definitely not something we guarantee.
2016-11-03 19:55:36 -04:00
Alexis Beingessner
7ec26fc976 fallout of renaming on tests which rely on internals
Some of these are kinda dubious, but I think this would be better
addressed as part of eager bridging, which will invalidate the concept
most of these are checking for.
2016-11-03 19:55:36 -04:00
Alexis Beingessner
052e94a34a refactor HashedCollections to support verbatim bridging 2016-11-03 19:52:30 -04:00
Max Moiseev
76e0a99a37 Merge branch 'master' into new-integer-protocols 2016-10-31 09:29:19 -07:00
Alexis Beingessner
76c6281fea [stdlib] Rewriting native hashed collection indices
Changes:
- Native dictionary and set indices no longer hold references to storage
- Cocoa-based dictionary and set indices no longer hold references to storage
- Removed double indirection trick from hashed collections
- Rewrote storage types to reflect simpler model
- Updated unit tests
2016-10-29 10:04:35 -04:00
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
Max Moiseev
3d4f00091d Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-10-28 15:55:40 -07:00
Pavel Yaskevich
dd01b7e184 [Diagnostics] SR-2208: Improve failure diagnostics for apply expressions 2016-10-26 14:34:05 -07:00
Max Moiseev
8d1155c2b9 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-10-17 11:29:07 -07:00
Max Moiseev
31ff53de61 [overlay] Don't call API in overlay tests
Overlay test in this particular case should only be concerned that the
API is available, not that the underlying implementation is correct.

Fixes: <rdar://problem/28702253>
2016-10-14 16:37:46 -07:00
Max Moiseev
08cf1de65a [WIP] fixing some of the integer related test failures 2016-10-05 15:25:23 -07:00
Max Moiseev
61ba07f033 Merge branch 'master' into new-integer-protocols 2016-09-27 11:59:42 -07:00
Andrew Trick
894be3703f Fix UnsafeBufferPointer validation test. (#5021)
There are several checks related to accessing a slice of an
UnsafeBufferPointer. Which tests are active depend on the level of
optimization. A raw buffer's checks are also stricter in some cases.

This test was originally designed to either crash or not for each input range
without regard to the nuances of when bounds checks are enabled. When an input
range was marked as crashing, that forced the test case to crash which was
self-fullfilling--nothing was really being tested in that case.

In my previous checkin, I enabled crash checking to be effective but missed some
of the nuances of different bounds checking modes. This commit adds logic to the test
to account for these nuances.
2016-09-26 17:31:09 -07:00
Max Moiseev
6803cda05c Merge branch 'master' into new-integer-protocols 2016-09-26 11:39:46 -07:00
Andrew Trick
9c729e4c0c SE-0138: UnsafeRawBufferPointer revision.
The withUnsafeMutableBytes closure argument should not be `inout`.

Improve testing, fix comments.

Addresses DaveA's review.
2016-09-25 19:56:21 -07:00
Andrew Trick
945cfc9342 Generalize UnsafeBufferPointer-as-a-Collection testing.
Fix some badly written tests with false positives.
Generalize the testing to cover raw buffer pointers.
2016-09-25 13:16:13 -07:00
Joe Groff
a506af06c7 Merge pull request #4933 from jckarter/nsnumber-bridging
SE-0139: Bridge all standard number types to NSNumber.
2016-09-23 13:06:43 -07:00
Joe Groff
9b1f238e5b SE-0139: Bridge all standard number types to NSNumber.
Extend NSNumber bridging to cover not only `Int`, `UInt`, `Double`, and `Bool`, but all of the standard types as well. Extend the `TypePreservingNSNumber` subclass to accommodate all of these types, so that we preserve type identity for `AnyHashable` and dynamic casting of Swift-bridged NSNumbers. If a pure Cocoa NSNumber is cast, just trust that the user knows what they're doing.

This XFAILs a couple of serialization tests that attempt to build the Foundation overlay, but which don't properly handle `gyb` files.
2016-09-23 10:34:22 -07:00
practicalswift
c4a6c054b1 Merge pull request #4855 from practicalswift/spacing-consistency
[gardening] Increase consistency with regards to spacing after colons
2016-09-23 11:20:23 +02:00
Doug Gregor
a60f7d7702 [AnyHashable tests] Minor NFC cleanup 2016-09-22 16:31:33 -07:00
Doug Gregor
6f34118cb6 [AnyHashable] Handle comparisons/casting for wrappers around bridged types.
Swift value types are their bridged Objective-C classes can have
different hash values. To address this, AnyHashable's responds to the
_HasCustomAnyHashableRepresentation protocol, which bridge objects of
those class types---NSString, NSNumber, etc---into their Swift
counterparts. That way, we get consistent (Swift) hashing behavior
across platforms.

However, there are cases where multiple Swift value types map to the
same Objective-C class type. In such cases, AnyHashable ends up
converting the object of class type back to some canonical type. For
example, an NS_STRING_ENUM (such as (NS)RunLoopMode) is a Swift
wrapper around a String. If an (NS)RunLoopMode is placed into an
AnyHashable, it maintains it's Swift type identity (which is correct
behavior). If it is bridged to Objective-C, it becomes an NSString; if
that NSString is placed into an AnyHashable, it produces a String. The
hash values still line up, but equality of the AnyHashable values
fails, which breaks when (for example) a dictionary with AnyHashable
keys is used from Objective-C. See SR-2648 / rdar://problem/27992351
for a case where this breaks interoperability.

To address this problem, make AnyHashable's casting and equality
sensitive to the origin of the hashed value: if the AnyHashable was
created through a _HasCustomAnyHashableRepresentation conformance,
treat comparisons/casting from it as "fuzzy":

* For equality, if one of the AnyHashable's comes from a custom
  representation (e.g., it originated with an Objective-C type like
  NSString) but the other did not, bridge the value of the *other*
  AnyHashable to Objective-C, re-wrap it in an AnyHashable, and
  compare that. This allows, e.g., an (NS)RunLoopMode created in Swift
  to compare to an NSString constant with the same string value.
* For casting, if the AnyHashable we're casting from came from a
  custom representation and the cast would fail, bridge to Objective-C
  and then initiate the cast again. This allows an NSString to be
  casted to (NS)RunLoopMode.

Fixes SR-2648 / rdar://problem/27992351.
2016-09-22 14:16:21 -07:00
practicalswift
ef8e43b519 [gardening] Increase consistency with regards to spacing after colons 2016-09-22 16:28:57 +02:00
Max Moiseev
ea8e0f0e15 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-09-21 14:48:35 -07:00
Erik Eckstein
9d631eb3d9 tests: use Set<Int> instead of Dictionary<Int, Void> 2016-09-20 16:34:51 -07:00
Erik Eckstein
8b1184708e stdlib: replace _squeezeHashValue with a specialized version for power-of-2 ranges.
This function is only used for Set and Dictionary and there the range (which is the capacity) is always a power of 2.
2016-09-20 16:34:51 -07:00
Greg Parker
9666d8d39a [test] Add a timeout to runRaceTest(). Use it to limit test AtomicInt.swift. (#4815)
[test] Add a timeout to runRaceTest(). Use it to limit test AtomicInt.swift.

This cuts AtomicInt.swift's execution time from several hours to
about ten minutes on slow hardware and slow build configurations.
2016-09-19 21:46:25 -07:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
practicalswift
2ee3c45b5b Merge pull request #4852 from practicalswift/optionals-set-to-nil
[gardening] Remove redundant nil-initialization of optional variables
2016-09-19 11:14:31 +02:00
Dave Abrahams
3bf6b60f1e Merge pull request #4825 from apple/stdlib-default-RangeReplaceableCollection.SubSequence
stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection
2016-09-18 20:49:53 -07:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Dmitri Gribenko
25378def9d stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection
Fixes rdar://problem/28330668.
2016-09-18 03:57:08 +03:00