Commit Graph

4740 Commits

Author SHA1 Message Date
Karoy Lorentey
8cf5bc8bdc [stdlib] Switch to using SipHash-1-3 as the standard hash function
Beyond switching hashing algorithms, this also enables per-execution hash seeds, fulfilling a long-standing prophecy in Hashable’s documentation.

To reduce the possibility of random test failures, StdlibUnittest’s TestSuite overrides the random hash seed on initialization.

rdar://problem/24109692
rdar://problem/35052153
2018-03-09 14:48:59 +00:00
Karoy Lorentey
42cab58554 [stdlib] Dictionary, Set: Use resilient hashing
This switches the primary hashing interface from hashValue to _hash(into:).
2018-03-09 14:35:19 +00:00
Karoy Lorentey
54b857ed0b [stdlib] Hashable: Add support for resilient hashing
Introduce _Hasher, representing an opaque hash compression function.

Add the method _hash(into:) as a Hashable requirement, decoupling the choice of hash function from Hashable's implementation. The default implementation of _hash(into:) has a default implementation that simply feeds hashValue to the hasher.

Add _hash(into:) implementations for the default integer types. Note that Int.hashValue does not return self anymore.

Add struct _LegacyHasher, emulating Swift 4.1 hashes in the new interface.
2018-03-09 14:34:57 +00:00
swift-ci
9bda1e5c55 Merge pull request #13340 from glessard/umbp-failearlyrangecheck 2018-03-08 05:38:39 -08:00
Karoy Lorentey
b52a94d789 [test] Fix tests relying on specific hash values or Set/Dictionary orderings
We shouldn't need to update regular tests if/when we modify the hash function.
2018-03-07 16:44:43 +00:00
Slava Pestov
47c6117a9b Sema: Remove deprecated SWIFT_FUNC_STAT counters 2018-03-06 19:42:52 -08:00
Slava Pestov
6065168928 Parse: Test that we only parse function bodies in primary files
I added this optimization a while ago but didn't add a test for it.
2018-03-06 19:42:43 -08:00
Doug Gregor
e49dbf5664 Merge pull request #15002 from DougGregor/gsb-ext-typealias-inherited-assoc-sr-7097
[GSB] Always ensure that we wire up typealiases in protocol extensions.
2018-03-06 09:57:23 -08:00
Jordan Rose
d8104e7e43 Evolution tests: Don't bother testing changing a class's superclass (#15000)
We're okay with saying this is a binary-breaking change, and its
presence in these tests is interfering with testing other things.

rdar://problem/36932507
2018-03-06 08:48:49 -08:00
Guillaume Lessard
0c95f902f0 restore debug-mode bounds checking to *BufferPointer.swapAt 2018-03-06 09:04:17 -07:00
Guillaume Lessard
116de2b3b2 non-mutating swapAt implementations for UnsafeMutable(Raw)BufferPointer 2018-03-06 09:04:16 -07:00
swift-ci
abbaa47614 Merge pull request #12504 from glessard/umbp-nonmutating-setter 2018-03-06 06:37:58 -08:00
Doug Gregor
823d2a990b [GSB] Always ensure that we wire up typealiases in protocol extensions.
During "expansion" of the requirements of a protocol, we check all of
the inherited associated types against definitions within the
protocol. Also look for concrete types within extensions of that
protocol, so we can identify more places where developers have used
typealiases in inheriting protocols to effect a same-type constraint
on an inherited associated type.

Fixes SR-7097 / rdar://problem/38001269.
2018-03-05 17:10:39 -08:00
Ben Cohen
7c99c68672 Add test for ArraySlice.popLast 2018-03-02 13:32:27 -08:00
Ben Cohen
2380950fa7 [stdlib] Collapse DropWhileBidirectionalCollection and de-gyb DropWhile.swift (#14906)
Collapse DropWhileBidirectionalCollection and de-gyb DropWhile.swift
2018-03-02 07:53:06 -08:00
Ben Cohen
f50afde523 Collapse PrefixWhileBidirectionalCollection and de-gyb PrefixWhile.swift (#14910) 2018-03-01 14:13:48 -08:00
Lance Parker
e0e50e9b3e Add failing test 2018-02-28 11:27:40 -08:00
Doug Gregor
46e623a089 [SubstitutionMap] Handle conformance lookup via superclass requirements.
Conformances that discoverably for a type parameter via a superclass
requirement occupy a bit of a gray area in the type checker and
generic signature handling right now: we have a type parameter (so the
paths that handle concrete conformances don't kick in), but the
conformance itself isn't modeled as a requirement because it is
available via lookup. Teach SubstitutionMap's conformance lookup to
detect this case and perform conformance lookup in the generic
signature (i.e., falling back to global lookup) in this case,
replicating the hack that IRGen uses to address the same issue when
accessing the conformance (see GenArchetype.cpp's TODO where we lookup
a conformance on the superclass). The removal of that hack (as well as
this one) are tracked by rdar://problem/34609744.

For now, fixes SR-7072 / rdar://problem/37904576.
2018-02-26 23:31:46 -08:00
Pavel Yaskevich
75e90cac20 Merge pull request #14798 from xedin/rdar-35870863
[TypeChecker] Fix crash related to chained optionals in case statements
2018-02-23 11:09:45 -08:00
Pavel Yaskevich
ea0427e9f9 [TypeChecker] Fix crash related to chained optionals in case statements
Type checker didn't handle the safe of disjoint optional chaining when trying
to convert such chaining into `.Some` cases, which leads to dangling
`BindOptionalExpr` in the AST.

Resolves: rdar://problem/35870863
2018-02-22 19:33:48 -08:00
Jordan Rose
63ec4e21fb Add a (tiny) test that adding "final" to a file rebuilds dependents
I can't see how we'd ever get this wrong at this point, but way back
in the early days of incremental builds we apparently managed to.
Adding a test just to close this out.

rdar://problem/23148987
2018-02-22 16:56:07 -08:00
Lance Parker
7cc222e271 Ditched the simple/complex test distinction as they all pass now (#20) 2018-02-19 10:09:24 -08:00
Lance Parker
0661de22a2 [stdlib]Un-revert string comparison (#14694)
Restore (un-revert) sting comparison, with fixes

More exhaustive testing of opaque strings, which consistently reproduces prior sporadic failure. Shims fixups. Some test tweaking.
2018-02-18 10:50:33 -08:00
Lance Parker
abe6a6d177 Revert string comparison (#14657) 2018-02-15 14:37:43 -08:00
Lance Parker
49bc1459ae Update string comparison tests 2018-02-14 15:44:11 -08:00
Mark Lacey
1aa5e8c925 Disable this test, which is failing in some branches. 2018-02-13 22:19:45 -08:00
Pavel Yaskevich
79d706463b Merge pull request #13664 from xedin/finalize-expr-type-cache
[ConstraintSystem] Only set types on expressions in presence of solution
2018-02-13 21:43:34 -08:00
swift-ci
86ccbd8b77 Merge pull request #14617 from DougGregor/gsb-avoid-unresolved-dependent-member-types 2018-02-13 18:06:08 -08:00
Doug Gregor
8b04dd3dbe [GSB] Avoid unresolved dependent member types in generic signatures.
The GenericSignatureBuilder is allowing unresolved dependent member
types to creep into generic signatures, which eventually blows up in
name mangling. Prefer to pick dependent member types that are
fully-resolved when choosing anchors.

This is a spot fix; a better approach would eliminate the notion of
unresolved dependent member types entirely from
PotentialArchetype. That's tracked by rdar://problem/35839277.

Fixes rdar://problem/36549499.
2018-02-13 15:40:53 -08:00
Pavel Yaskevich
8c17b925e6 [ConstraintSystem] Add TypeLoc caching to constraint system
This is useful for explicit casts and type expressions, where
type loc and expression types might be different, and allows
constraint solver to avoid setting opened types to expressions
which resolves multiple crashes.
2018-02-13 00:08:56 -08:00
Mark Lacey
37009b0d8b [ConstraintSystem] Remove constraint propagation.
The current implementation isn't really useful in the face of generic
overloads. It has never been enabled by default, and isn't useful to
keep around if it is disabled. If we ever want to bring it back,
we know where to look!
2018-02-12 21:30:39 -08:00
Joe Groff
4cffc9fa3f Update validation tests for diagnostic message change from #14391. 2018-02-09 11:56:04 -08:00
Doug Gregor
dee02c42a4 Update test cases for constraint solver performance hack 2018-02-08 22:57:05 -08:00
Doug Gregor
3d32e89e33 [Constraint solver] Favor more-specialized overload among two generics.
When we form an overload set containing two generic functions, where
one is more specialized than the other, "favor" the more-specialized
function in the constraint system so we won't explore any paths
involving the less-specialized function when the more-specialized
version applies. This should be a strict improvement, because
previously we would have always gone down both paths.

Fixes rdar://problem/37371815, taking this exponential example linear.
2018-02-08 20:41:13 -08:00
Jordan Rose
f9299e711c [test] rth: Use dynamic linking to properly test backwards-deployment (#14447)
The added test worked before as well; it's to make sure I didn't break
the existing behavior.
2018-02-08 17:14:10 -08:00
Pavel Yaskevich
c6ff7b40cc [CSBindings] Look through optional types when trying to validate l-valueness of the new bindings
When bindings are picked for particular type variable, right-hand
side of the binding might be another type variable wrapped into optional
type, when trying to determine if both sides of the binding have the
same l-valueness it's imperative to look throught optional type of the
right-hand side. Otherwise new binding might be effectively unsolvable.

Resolves: rdar://problem/37291371
2018-02-08 01:55:39 -08:00
Pavel Yaskevich
1a0221398b Merge pull request #14419 from xedin/rdar-36989792
[DeclChecker] Don't try to derive conformances for invalid enums
2018-02-05 16:43:45 -08:00
Pavel Yaskevich
38e305cfdc [DeclChecker] Don't try to derive conformances for invalid enums
If one of the cases is invalid, let's mark parent enum as invalid
as well, and avoid trying to derive any conformances related to it.

Resolves: rdar://problem/36989792
2018-02-05 14:12:55 -08:00
Ben Cohen
415d90c72c Move collection compat test that needs StdlibCollectionUnittest to validation-test 2018-02-05 13:19:41 -08:00
Huon Wilson
bc37733daf Merge pull request #14293 from huonw/nested-conditional-types
[GSB] Infer requirements from parents of types.
2018-02-05 09:50:10 +11:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Ben Cohen
072aedcdb7 Use LifetimeTracked for Array.popLast test (#14334) 2018-02-01 19:47:28 -08:00
Pavel Yaskevich
fb199ffb92 [TypeChecker] Mark perf test-case for rdar://problem/22282851 as fast
Recent changes to contraction of the closure argument/parameter type
variables resulted in speed up in type-checker performance which resolved
one of existing "slow" test-cases.
2018-02-01 15:27:37 -08:00
Huon Wilson
9aed3e83a8 [GSB] Infer requirements from parents of types.
A type Foo<...>.Bar may only exist conditionally (i.e. constraints on the
generic parameters of Foo), in which case those conditional requirements
should be implied when Foo<...>.Bar is mentioned.

Fixes SR-6850.
2018-02-02 08:44:30 +11:00
Pavel Yaskevich
d49d8f0c5d Merge pull request #14308 from xedin/rdar-36838495
[CSSolver] Fix performance regression related to contraction of closure parameters
2018-01-31 15:52:45 -08:00
Pavel Yaskevich
3b7e555c7e [CSSolver] Fix performance regression related to contraction of closure parameters
Improve situation around closure parameter/argument contractions
by allowing such action if it can be proved that none of the bindings
would result in solver attempting to bind parameter to `inout` type.

Resolves: rdar://problem/36838495
2018-01-31 14:21:14 -08:00
Karoy Lorentey
77992d37f0 Merge pull request #14033 from lorentey/rdar/35995647
[Foundation] Coalesce duplicate String keys in bridged NSDictionary and NSSet
2018-01-31 11:57:31 +00:00
Andrew Trick
dd2e3480e2 Add a test case for AST verification of loaded modules in WMO.
Prior to the following commit, the SILVerifier will assert
on this test case.

PR: 14250 <https://github.com/apple/swift/pull/14250>

commit deebe8b9c7
Author: Andrew Trick <atrick@apple.com>
Date:   Mon Jan 29 15:22:28 2018

    performTypeChecking: Defer verifyAllLoadedModules in WMO mode.
2018-01-30 13:55:08 -08:00
Pavel Yaskevich
6a45971c3c [IRGen/Resilience] Add a test case for rdar://problem/36560486
Since field offsets are now encoded after generic parameters, it
is useful to validate that using generic parameter metadata is now
more resilient in presence of new fields.
2018-01-29 23:25:29 -08:00
Greg Parker
e223f1fc9b [IRGen][runtime] Simplify runtime CCs and entry point ABIs (#14175)
* Remove RegisterPreservingCC. It was unused.
* Remove DefaultCC from the runtime. The distinction between C_CC and DefaultCC
  was unused and inconsistently applied. Separate C_CC and DefaultCC are
  still present in the compiler.
* Remove function pointer indirection from runtime functions except those
  that are used by Instruments. The remaining Instruments interface is
  expected to change later due to function pointer liability.
* Remove swift_rt_ wrappers. Function pointers are an ABI liability that we
  don't want, and there are better ways to get nonlazy binding if we need it.
  The fully custom wrappers were only needed for RegisterPreservingCC and
  for optimizing the Instruments function pointers.
2018-01-29 13:22:30 -08:00