Commit Graph

1800 Commits

Author SHA1 Message Date
Mark Lacey
78d83e5703 Use %target-typecheck-verify-swift where possible. 2018-07-26 23:13:43 -07:00
Doug Gregor
059163360a Re-enable Lazy test on Linux.
Arnold fixed this by re-computing the insert position in
getSpecializedConformance(), with
https://github.com/apple/swift/pull/17904.

Fixes rdar://problem/35797159.
2018-07-26 16:07:37 -07:00
Pavel Yaskevich
84cd99a3eb [Diagnostics] Enable extraneous/incorrect label diagnostics via solver fixes
This builds on initial commit which added `RelabelArguments` fix
to the solver that only supported `missingLabels` at that moment,
but now it supports all three posibilities - missing/extraneous and
incorrect labels.
2018-07-25 14:34:26 -07:00
Ben Cohen
345879429b [stdlib] Take several underscored stdlib functions private (#18134)
* Make _sanityCheck internal

* Make _debugPrecondition internal

* Make Optional._unsafelyUnwrappedUnchecked internal.

* Make _precondition internal

* Switch Foundation _sanityChecks to assertions

* Update file check tests

* Remove one more _debugPrecondition

* Update Optimization-with-check tests
2018-07-24 18:26:19 -07:00
Ben Cohen
34610780fd Break out conformances into extensions (#18098)
Replace LoggingRangeReplaceableCollection variants with typealiases

Replace LoggingMutableCollection variants with typealiases.

Collapse BufferAccessLoggingMutableCollection variants into typealiases

Turn LoggingRandomAccessCollection into a typealias

Turn LoggingBidirectionalCollection into a typealias
2018-07-20 12:50:12 -07:00
Mark Lacey
5828a98874 Merge pull request #18032 from rudkx/restore-order
Return to the old disjunction ordering until some test regressions are addressed.
2018-07-17 20:19:35 -07:00
Ben Cohen
074dc43c3e Restore Sequence conformance to FlattenSequence.Iterator (#18024) 2018-07-17 20:00:30 -07:00
Mark Lacey
7fd052efd8 Revert the effect of 6fa403dc7d.
For the moment, return to the old ordering for disjunctions as the new
ordering regressed some type checker performance tests.
2018-07-17 17:27:19 -07:00
Ben Cohen
be894e4510 Replace Random.default with SystemRandomNumberGenerator (#17989) 2018-07-17 13:17:06 -07:00
Mark Lacey
6fa403dc7d [ConstraintSystem] Change the order in which we attempt disjunctions
to be stable.

We currently will stop visiting the elements of a disjunction under
certain circumstances once we have found a solution. The result we get
is inherently dependent on the order in which we determine to visit
the disjunctions themselves (in addition to the elements of the
disjunction).

This change makes the order in which we visit disjunctions
stable. Future commits will create a stable ordering for the elements
of disjunctions. Once we also have that stable ordering in place we
can in theory short circuit more often as part of changing the way in
which we decide what the "best" solution is to a system.

This results in an expression in
validation-test/stdlib/AnyHashable.swift.gyb no longer being able to
typecheck in a reasonable amount of time, so I had to tweak that
expression.
2018-07-16 09:32:14 -07:00
Ben Cohen
bd7171bedf [stdlib] De-gyb Sort (#17954)
* [stdlib] De-gyb Sort
2018-07-15 14:23:06 -07:00
Michael Ilseman
c8ed8f9a2f [test] Update String tests for older iOS versions 2018-07-13 16:08:36 -07:00
Karoy Lorentey
d2861f779e [test] Re-add crash tests for getObjects:andKeys:count:
On some platforms, when a new process is started, ARC’s autoreleased return value optimization is expected to fail the first time it is used in each linked dylib. StdlibUnittest takes care of warming up ARC for the stdlib (libswiftCore.dylib), but for Dictionary.swift, we also need to do it for Foundation, or there will be spurious leaks reported for tests immediately following a crash test.

Add the necessary dummy operations to setUp, and re-add the crash tests that were removed in #17862. (As separate tests this time, so they don’t hide leaks in non-crashing test parts.)
2018-07-13 15:32:52 +01:00
Karoy Lorentey
4832e0ed46 [test] Fix leak and reenable getObjects:andKeys:count: tests 2018-07-12 18:33:00 +01:00
Karoy Lorentey
d1fd33f9b0 [test] Disable getObjects:andKeys:count: tests.
Removing crash tests fixed optimized test runs, but exposed an issue in unoptimized i386 simulator tests.

Disable the two affected tests until we plug all their holes.
2018-07-11 01:42:30 +01:00
Karoy Lorentey
6c97fe4db8 [test] Reenable previously disabled Dictionary tests 2018-07-10 22:42:22 +01:00
Karoy Lorentey
68a5331712 [test] Fix Dictionary failures; reenable previously disabled tests
Crashes somehow interfere with object counters in optimized tests, breaking the tests immediately following a crash test.

Remove getObjects:andKeys:count: crash tests for now.

rdar://problem/41871587
2018-07-10 22:41:54 +01:00
Karoy Lorentey
ea98396dbd [test] Skip two Dictionary tests to unblock CI 2018-07-10 13:13:59 +01:00
Ben Cohen
685f31b0e2 [stdlib] Migrate stdlib tests of Swift 3 (#17427)
* First sweep of Swift 3 stdlib test upgrades

* Review feedback

* Remove a handful more #if >=4.0

* Fix up Dictionary tests
2018-07-08 09:37:01 -07:00
Mark Lacey
dec3341ee0 Merge pull request #17748 from rudkx/remove-swift3-from-some-tests
Remove -swift-version 3 from a handful of tests and update them appro…
2018-07-06 15:59:40 -07:00
Alejandro
79cb33fa78 [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794) 2018-07-06 13:13:19 -04:00
Mishal Shah
95c80cf2ce Merge pull request #17761 from apple/update-master-xcode-10-beta-3
Update master to build with Xcode 10 beta 3, macOS 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs
2018-07-05 15:53:29 -07:00
Mishal Shah
811b1d0879 Update master to build with Xcode 10 beta 3, OS X 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs 2018-07-05 10:57:03 -07:00
Karoy Lorentey
91bb2c0a6c [test] check getObjects:andKeys:count: implementations in bridged Dictionaries 2018-07-05 15:52:11 +01:00
Mark Lacey
5e75b1ad3b Remove -swift-version 3 from a handful of tests and update them appropriately.
These are all tests that would otherwise fail if the expression type
checker support for Swift 3 is removed.

I've moved some of the code from deleted Migrator tests into new
Constraints tests that verify that we do not support the constructs.
2018-07-04 20:58:21 -07:00
Karoy Lorentey
f8e6c304e0 [test] AnyHashable: Shorten class hierarchy tests
AnyHashable.swift.gyb is by far the longest test in debug builds of the test suite. Cut it dramatically shorter by reducing the number of equivalence classes checked in “containing classes from the <foo> hierarchy” tests from 16 down to 3.

(It seems to me the extra test cases didn’t actually test any additional functionality.)
2018-07-02 21:27:37 +01:00
Karoy Lorentey
a4e9109618 Merge pull request #17396 from lorentey/anyhashable-is-not-hashable
[stdlib] Fix AnyHashable's Equatable/Hashable conformance
2018-06-29 17:38:08 +01:00
Ben Cohen
a4230ab2ad [stdlib] Update stdlib to 4.0 and reorganize compatibility shims (#17580)
* Update stdlib to 4.0 and move all compatibility shims into a dedicated source file
2018-06-29 06:26:52 -07:00
Huon Wilson
350f7d8494 [test] Move test using StdlibCollectionsUnittest to validation-test. 2018-06-26 17:43:40 +10:00
Ben Cohen
a51cc89b11 Replace _CharacterView with a typealias (#17472) 2018-06-25 13:22:09 -07:00
Karoy Lorentey
bf872ec157 [stdlib][SE-0206] Use distinct hash encodings for standard integer types
Fix Hashable conformance of standard integer types so that the number of bits they feed into hasher is exactly Self.bitWidth.

This was intended to be part of SE-0206. However, it would have introduced additional issues with AnyHashable. The custom AnyHashable representations introduced in the previous commit unify hashing for numeric types, eliminating the problem.
2018-06-25 20:14:17 +01:00
Karoy Lorentey
ff91f36a9d [stdlib] Fix AnyHashable's Equatable/Hashable conformance
AnyHashable has numerous edge cases where two AnyHashable values compare equal but produce different hashes. This breaks Set and Dictionary invariants and can cause unexpected behavior and/or traps. This change overhauls AnyHashable's implementation to fix these edge cases, hopefully without introducing new issues.

- Fix transitivity of ==. Previously, comparisons involving AnyHashable values with Objective-C provenance were handled specially, breaking Equatable:

    let a = (42 as Int as AnyHashable)
    let b = (42 as NSNumber as AnyHashable)
    let c = (42 as Double as AnyHashable)
    a == b // true
    b == c // true
    a == c // was false(!), now true

    let d = ("foo" as AnyHashable)
    let e = ("foo" as NSString as AnyHashable)
    let f = ("foo" as NSString as NSAttributedStringKey as AnyHashable)
    d == e // true
    e == f // true
    d == f // was false(!), now true

- Fix Hashable conformance for numeric types boxed into AnyHashable:

    b == c // true
    b.hashValue == c.hashValue // was false(!), now true

  Fixing this required adding a custom AnyHashable box for all standard integer and floating point types. The custom box was needed to ensure that two AnyHashables containing the same number compare equal and hash the same way, no matter what their original type was. (This behavior is required to ensure consistency with NSNumber, which has not been preserving types since SE-0170.

- Add custom AnyHashable representations for Arrays, Sets and Dictionaries, so that when they contain numeric types, they hash correctly under the new rules above.

- Remove AnyHashable._usedCustomRepresentation. The provenance of a value should not affect its behavior.

- Allow AnyHashable values to be downcasted into compatible types more often.

- Forward _rawHashValue(seed:) to AnyHashable box. This fixes AnyHashable hashing for types that customize single-shot hashing.

https://bugs.swift.org/browse/SR-7496
rdar://problem/39648819
2018-06-25 20:14:01 +01:00
swift-ci
6ed6b2fd9b Merge pull request #17408 from airspeedswift/one-is-the-loneliest-iterator 2018-06-22 11:54:26 -07:00
Ben Cohen
2eec236f13 Move two more Iterators into nested types 2018-06-21 16:28:20 -07:00
Slava Pestov
e07aefbe74 stdlib: Add -swift-version 3 to two more tests 2018-06-20 22:55:38 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Michael Ilseman
1fe5fb717d [string] Skip allocation in reserveCapacity if smol
If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.
2018-05-18 21:26:59 -07:00
Arnold Schwaighofer
8a36d2d8ce Codesign the executable in test MicroStdlib
rdar://40339165
2018-05-17 11:51:53 -07:00
Michael Ilseman
4a368ab46c [string] Drop many @inlinable from big API.
Drop append-related @inlinable annotations for String, StringGuts,
StringStorage, and the Views. Drop several for larger operations, such
as case conversion. Drop as many as we can from StringGuts for now.
2018-05-13 07:38:55 -07:00
Michael Ilseman
459833725e [String] Streamline more String creation logic.
Streamline and de-genericize non-inlinable internal functions to
create a String from UTF-8 efficiently.
2018-05-13 07:38:55 -07:00
Huon Wilson
6015709a92 Merge pull request #16523 from huonw/conditionalize-float80
[test] Float80 only exists on some platforms.
2018-05-11 13:14:49 +10:00
Huon Wilson
6de8b18689 [test] Float80 only exists on some platforms. 2018-05-11 12:23:21 +10:00
Huon Wilson
8178807ca0 [test] Non-determinism down to 0.999999 (1-in-a-million) rather than 0.999.
With the number of tests Swift does, this had a relatively high chance to fail
regularly somewhere.

Also, rejecting the lower tail means rejecting things that are perfectly
uniform, which I don't think should be the purpose of this test.
2018-05-11 09:56:12 +10:00
Andrew Trick
6a48b2d02d Merge pull request #16491 from atrick/enforce-keypath-exclusivity-as-error
Enforce keypath exclusivity as an error.
2018-05-10 16:03:01 -07:00
Karoy Lorentey
c03fe15caf [test] Move Random tests under validation-test
StdlibCollectionUnittest is not available in smoke tests.
2018-05-10 19:47:14 +01:00
Andrew Trick
5b1b730662 Fix a static exclusivity violation in OpenCLSOverlay.swift.
I noticed this during testing, but it has nothing to do with the other changes
in this PR. This static violation has always been present as a warning and would
continue to be a warning after my changes.
2018-05-10 10:56:29 -07:00
Erik Eckstein
b519d1d873 stdlib: Speed up UTF8View -> Array conversion by using _copyContents 2018-05-08 13:52:05 -07:00
Karoy Lorentey
08940d5e92 [test] Merge Dictionary4 into Dictionary
Dictionary's Hashable conformance is not gated to Swift 4 mode.
2018-04-30 15:40:16 +01:00
Karoy Lorentey
c8d43eb34d [test] Cover Hasher's top-level hashing functions 2018-04-30 15:40:16 +01:00
Karoy Lorentey
5b80cf1d59 [stdlib]: Set,Dictionary: Fix subtle cross-collection hash collision issue
When Set/Dictionary is nested in another Set, the boundaries of the nested collections weren’t correctly delineated in commutative hashing.

For example, these Sets all hashed the same:

[[1, 2], [3, 4]]
[[1, 3], [2, 4]]
[[1, 4], [2, 3]]

Hash collisions could thus be systematically generated.

To fix this, remove collection-level support for one-shot hashing and revert to the previous method of generating hash values. (Set is still able to support one-shot hashing for its members, though.)
2018-04-30 15:40:16 +01:00