Commit Graph

144 Commits

Author SHA1 Message Date
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Karoy Lorentey
9fef06e59c Merge pull request #12752 from hamishknight/dictionary-subscript-addressor
[stdlib] Use addressor for Dictionary's subscript(_:default:)
2017-12-04 15:04:29 +01:00
Nate Cook
9dce40ca24 [stdlib] Add tests for index hashability 2017-11-28 13:29:55 -06:00
Arnold Schwaighofer
48d11bd540 stdlib: Fix test cases Dictionary.swift and Set.swift
After the llvm inliner fix to correctly handle notail calls we don't need this
anymore.

rdar://35639547
2017-11-27 12:21:46 -08:00
Hamish
79d8209ffa [stdlib] Use addressor for Dictionary's subscript(_:default:) 2017-11-19 15:45:27 +00:00
Michael Gottesman
89cefe0a70 [stdlib] Use a different access pattern to check uniqueness to work around more conservative SILGen codegen.
Using && here causes us to go down a SILGen path that guarantees that self will
be evaluated over the entire && expression instead of just the LHS. This cause
the uniqueness check to always return false at -Onone. At -O, the optimizer is
smart enough to remove this issue.

rdar://33358110
2017-11-18 20:16:28 -07:00
Arnold Schwaighofer
0971d82f70 SILGen: Remaining fixes for @callee_guaranteed closures and enable it
- Fix block to func reabstraction thunks block argument handling
- Forward cast ownership
- Fix applyPartiallyAppliedSuperMethod ownership for @callee_guaranteed closures
- Avoid a copy in buildBlockToFuncThunkBody
- Update tests for callee_guaranteed closures

SR-5441
rdar://33255593
2017-11-15 19:46:08 -08:00
Lance Parker
a386f747ed Removed more occurrences of the incorrect comment 2017-09-19 16:26:36 -07:00
Lance Parker
3c8f5fa04a Add COW test for Array 2017-08-28 17:20:18 -07:00
Michael Gottesman
ab6a4f5249 Disable some failing tests.
rdar://33358110
2017-07-19 16:25:39 -07:00
Nate Cook
41ea7e296c Merge pull request #10113 from natecook1000/nc-dict-tuples
[stdlib] Add dictionary overloads for merging methods
2017-06-06 14:58:15 -07:00
Nate Cook
a48e7fd954 [stdlib] Test that dictionaries can be passed to merge/merging 2017-06-05 15:54:16 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Nate Cook
b71e2636c4 Update dictionary tests 2017-05-10 11:27:34 -05:00
Nate Cook
5aed293cde [stdlib] Fix test for different hash layouts 2017-05-02 15:27:49 -05:00
Nate Cook
5da1ce032f [stdlib] Fix order for Dictionary.keys/values tests 2017-05-02 09:48:22 -05:00
Nate Cook
2e2e4d9bda Revert "Revert "[stdlib] Dictionary/Set enhancements""
This reverts commit 328ebe8567.
2017-05-01 16:06:14 -05:00
Arnold Schwaighofer
328ebe8567 Revert "[stdlib] Dictionary/Set enhancements" 2017-04-29 07:02:57 -07:00
Nate Cook
e2328885c1 [stdlib] Dictionary/Set enhancements
A variety of enhancements from SE-154 and SE-165:

- Custom Keys and Values collections for Dictionary
- Two sequence-based Dictionary initializers
- Merging methods for Dictionary
- Capacity checking and reserving for Dictionary and Set
- Type-specific filter(_:) methods for Dictionary and Set
- A mapValues(_:) method for Dictionary
- A grouping Dictionary initializer
2017-04-26 11:21:16 -05: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
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
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
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
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
1031efeabc Dictionary test: fix intermittent failures
The test was using an index from one dictionary with a different
dictionary instance.
2016-09-17 21:13:26 +03:00
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Doug Gregor
57f1090a11 Revert "[Set/Dictionary] Eliminate "bridging" collection entrypoints."
This reverts commit dc0ae675bc. The
change here (presumably the change to Foundation) caused a regression
in several of the bridging-related benchmarks, e.g.,
ObjectiveCBridgeFromNSSetAnyObjectToString, DictionaryBridge,
ObjectiveCBridgeFromNSDictionaryAnyObjectToString.
2016-08-24 13:20:03 -07:00
Doug Gregor
dc0ae675bc [Set/Dictionary] Eliminate "bridging" collection entrypoints.
Remove the functions
_(set|dictionary)Bridge(From|To)ObjectiveC(Conditional) from the
standard library. These entrypoints are no longer used by the compiler
(thanks to generalized collection up/downcasting), so stop using them
in Foundation and in tests.
2016-08-22 15:14:09 -07:00
Xiaodi Wu
f9435b9ce8 [stdlib] Restore MemoryLayout.*(ofValue:) 2016-08-08 10:46:37 -05:00
Jordan Rose
f42158b12e Revert "[Sema] ban multi-arguments to tuple coercion" (#3922)
It breaks cases where there really is a single unlabeled argument of tuple type, like this:

  let pairs = [(1, "A"), (2, "B")]
  print(pairs.map { $0.0 })
2016-08-01 19:22:19 -07:00
Daniel Duan
c9b73dacc2 [Sema] ban multi-arguments to tuple coercion
Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```

This patch does not implement that part.
2016-07-31 16:22:57 -07:00
Joe Groff
c748ba6c12 Merge pull request #3870 from jckarter/no-bridged-default-literal-types
Sema: Don't try bridged classes as default literal types.
2016-07-29 22:16:53 -07:00
Dmitri Gribenko
99dffd7682 Merge pull request #3854 from rintaro/SE-0101-memorylayout
[SE-0101] Implement: Reconfiguring sizeof and related functions into a unified MemoryLayout struct - Part 1
2016-07-29 15:56:27 -07:00
Joe Groff
11f03cd8b5 Sema: Don't try bridged classes as default literal types.
One last bit of SE-0072. We shouldn't fall back to bridged classes in the absence of type context for literals anymore. By itself, this kind of hoses the use of literals with NS types, but I think we can get most of the QoI back with overlay changes I plan to propose following this.
2016-07-29 15:18:31 -07:00
Rintaro Ishizaki
c6f4bcd01e [SE-0101] MemoryLayout: Migrate testsuite and benchmarks 2016-07-30 03:11:45 +09:00
Arnold Schwaighofer
c65e1a31e3 Fix _bridgeToObjectiveC lookup code in optimizeBridgedSwiftToObjCCast
Previously it assumed that if we succeed in looking up the method in the current
module we must be able to request a definition (vs a declaration).

This is not true. It could be that we had declared the type in a different
module. Always ask for a declaration.

rdar://27547957
2016-07-28 14:54:16 -07:00
Arnold Schwaighofer
37b789007d Disable Dictionary/Set.swift tests that fail in optimize mode
Disable the tests in optimize mode until we have fix to unblock builders.

rdar://27547957
2016-07-27 07:50:32 -07:00
Joe Groff
f1c0334d29 Autoreleasepool NSDictionary conversions in Dictionary validation tests.
Not sure if this is by design (cc @gribozavr), but the test harness counts the bridged values in these dictionaries as "leaks" if they aren't popped early.
2016-07-25 07:25:47 -07:00
Joe Groff
21c15d8fe9 Update validation tests for id-as-Any. 2016-07-25 06:40:37 -07:00
Andrew Trick
5a8271c621 Rename UnsafePointer allocate & deallocate. (#3608)
As proposed in SE-0107: UnsafeRawPointer:
Rename 'init(allocatingCapacity:)' to 'UnsafeMutablePointer.allocate(capacity:)'
Rename 'deallocateCapacity' to 'deallocate(capacity:)'

`allocate` should not be an initializer. It's primary function is to allocate
memory, not initialize a pointer.
2016-07-19 11:48:18 -07:00
Austin Zheng
d8b5a2a4fd [stdlib] Improving Dictionary/Set tests to use fewer unsafeBitCasts
NFC
2016-06-24 10:12:16 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
Rintaro Ishizaki
1bdce7ced6 [lit] Add substitutions: %utils and %line-directive
%utils => ${SWIFT_SOURCE_DIR}/utils
%line-directive => ${SWIFT_SOURCE_DIR}/utils/line-directive
2016-06-11 02:41:15 +09:00
Rintaro Ishizaki
4d686a424f [Parser] Don't report AttrsRequiringFoundation in inactive config block
Fixes rdar://problem/23487944
2016-05-26 02:43:21 +09:00
swift-ci
9af514f994 Merge pull request #2544 from rintaro/test-nondarwin-1 2016-05-16 21:30:10 -07:00
Dmitri Gribenko
0868b6f70c stdlib: Dictionary, Set: allow querying for a mismatched type when bridged
Swift's Dictionary and Set are typed, but when bridged to NSDictionary
and NSSet they should behave accordingly, that is, allow querying for
keys of arbitrary types.

rdar://problem/23679193
2016-05-16 15:30:44 -07:00
Rintaro Ishizaki
52ecb88256 [stdlib] Enable Dicitionary validation test on non-Darwin platforms 2016-05-17 03:06:58 +09:00
Ted Kremenek
d3c41c4668 Revert "Revert "SE-0072: Fully eliminate implicit bridging conversions from Swift"" (#2441) 2016-05-06 23:26:45 -07:00
Ted Kremenek
4df003c291 Revert "SE-0072: Fully eliminate implicit bridging conversions from Swift" (#2440) 2016-05-06 23:22:56 -07:00
Joe Pamer
6af546e89e Merge pull request #2419 from apple/se-0072
SE-0072: Fully eliminate implicit bridging conversions from Swift
2016-05-06 22:14:13 -07:00