Commit Graph

5277 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
adfaf8bab4 Merge pull request #16394 from xedin/rdar-39909829
[Parser] Set decl context to be typealias when completing its underly…
2018-05-07 14:14:37 -07:00
Pavel Yaskevich
f49aad16b7 [Parser] Set decl context to be typealias when completing its underlying type
Parser didn't capture correct context when code completion
was attempted on typealias' right-hand side which, if there are
generic parameters present, would result in a crash. These
changes make it so completion gets a correct declaration
context in aforementioned case and typealias declaration is marked
invalid because it doesn't have a proper type.

Resolves: rdar://problem/39909829
2018-05-04 17:39:55 -07:00
Doug Gregor
539c352353 [GenericSignatureBuilder] Block recursion through getTypeInContext().
We could end up recursing through getTypeInContext() before we had time to
diagnose the recursion, so be *certain* that we can't recurse here to fix
a few crashes.
2018-05-03 18:11:35 -07:00
Pavel Yaskevich
01312d9623 Merge pull request #16276 from xedin/add-implicit-inits-with-getparams
[Sema] Refactor member type matching from `checkOverrides` to make it reusable
2018-05-03 00:16:24 -07:00
Doug Gregor
9c5a222b95 Merge pull request #16291 from DougGregor/ast-use-substitution-map
[AST] Store SubstitutionMaps in the AST rather than Substitution lists.
2018-05-02 23:52:18 -07:00
Pavel Yaskevich
394ac6f4f1 [AST] lookupSubstition should produce nothing if there are not substitutions
If `SubstitutionMap` is empty there is nothing to replace so
we should always return empty substitution type and/or conformance ref.
2018-05-02 15:11:25 -07:00
Doug Gregor
bc5bbe8b64 [AST] Use SubstitutionMap, not SubstitutionList, in SILBoxType.
Eliminate the last place in the AST proper that stores
SubstitutionLists rather than SubstitutionMaps. Randomly fixes a
crasher, too.
2018-05-02 13:39:21 -07:00
Mishal Shah
b93eeed850 Update llvm-dwarfdump to use -apple-types vs -debug-dump=apple_types 2018-05-02 09:16:22 -07:00
Mishal Shah
607d449ddc Update llvm-dwarfdump to use --debug-line vs -debug-dump=line 2018-05-02 09:12:32 -07:00
Slava Pestov
d466ddfe6e %target-typecheck-verify-swift already expands to the file name 2018-04-30 18:57:17 -06: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
Karoy Lorentey
3a162d225a [stdlib] Hashable, Hasher: Add non-public top-level hashing interface
The new _rawHashValue(seed:) requirement allows stdlib types to specialize their hashing when they’re hashed on their own (i.e., not as a component of some composite type).

This makes it possible to get rid of discriminator/terminator values and to eliminate most of Hasher’s resiliency overhead, leading to a measurable speedup, especially for tiny keys.
2018-04-30 15:16:47 +01:00
Huon Wilson
69d41e7184 [test] Add test for rdar://problem/37730691. 2018-04-30 12:16:27 +10:00
Michael Ilseman
715003c206 [gardening] Internalize many non-API String interfaces 2018-04-28 15:36:05 -07:00
Ben Cohen
d6444f5f27 Add Sequence.allSatisfy 2018-04-27 08:53:35 -07:00
Huon Wilson
d23bd75358 Merge pull request #16172 from huonw/protocol-typealias-crash
[Sema] Ensure that NameAliasTypes record the right substitutions.
2018-04-27 13:05:15 +10:00
Huon Wilson
be5a3abcd6 [Sema] Ensure that NameAliasTypes record the right substitutions.
If a typealias is inside a protocol, and things are defined in a certain order,
the NameAliasType for that typealias can be constructed before the parent
protocol has been validated (i.e. before its generic environment exists), in
which case it is missing the necessary substitutions.

Fixes rdar://problem/39636312.
2018-04-26 23:55:54 +10:00
Slava Pestov
0cbbd9ae5d Sema: Don't set 'validation started' bit on ParamDecls from validateDecl()
Otherwise, when the horrible ExprCleanser comes along, it will set
the interface type of the ParamDecl to nullptr. However there is
no way to clear the 'validation started' bit, so the next time
validateDecl() is called on this ParamDecl we will just return,
causing crashes downstream when callers expect it to already have
an interface type set.

Fixes <rdar://problem/38189778> and possibly some instances of
<rdar://problem/36434823>.
2018-04-25 18:04:58 -07:00
Karoy Lorentey
1e1f6b8d92 [stdlib] Remove obsolete hashing interfaces 2018-04-24 17:55:35 +01:00
Karoy Lorentey
97ec2967e0 [SE-0206][stdlib] Hasher, SipHash: Make non-public declarations internal
Newly internal declarations include Hasher._seed and the integer overloads of Hasher._combine(_:), as well as _SipHash13 and _SipHash24.

Unify the interfaces of these SipHash testing structs with Hasher. Update SipHash test to cover Hasher, too.

Add @usableFromInline to all newly internal stuff. In addition to its normal use, it also enables white box testing; compile tests that need to use these declarations with -disable-access-control.
2018-04-24 17:42:42 +01:00
Karoy Lorentey
45cb8b7123 [SE-0206][stdlib] De-underscore Hasher 2018-04-24 17:42:42 +01:00
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Karoy Lorentey
67852ed460 Merge pull request #16066 from lorentey/better-hash-tests
[stdlib] Review & update hash testing to use Hasher's new features
2018-04-21 23:42:38 +01:00
Doug Gregor
7177b23f93 Merge pull request #16069 from DougGregor/sr-7364
[Conformance checking] Diagnose missing witnesses along "lazy" paths.
2018-04-20 13:27:38 -07:00
Karoy Lorentey
6984782229 [test] PersistentVector: use a custom hashing interface
This prototype is not fully implemented, and it relies on specific hash values to not trigger unhandled cases.

To keep its test working, define and use a custom hashing interface that emulates hashValue behavior prior to SE-0206.
2018-04-20 19:22:19 +01:00
Karoy Lorentey
21932f4227 [test] Override hash, not hashValue in NSObject subclasses 2018-04-20 19:22:19 +01:00
Karoy Lorentey
5ab67115dc [test] MinimalHashable types: Replace hashValue hook with hash(into:) 2018-04-20 19:22:19 +01:00
Karoy Lorentey
8d18d1a55d [test] checkHashable: Check that unequal values produce different hashes
This is safe to do with hash(into:), because random hash collisions can be eliminated with awesome certainty by trying a number of different hash seeds. (Unless there is a weakness in SipHash.)

In some cases, we intentionally want hashing to produce looser equivalency classes than equality — to let those cases keep working, add an optional hashEqualityOracle parameter.

Review usages of checkHashable and add hash oracles as needed.
2018-04-20 19:22:19 +01:00
Doug Gregor
8146d25641 [Conformance checking] Diagnose missing witnesses along "lazy" paths.
When lazily resolving witnesses, we would fail to diagnose missing
witnesses for which we had no specific diagnostic to give, leading to
AST verifier errors and crashes later on. Make sure we call the
operation to diagnose missing witnesses along these paths, too.

Fixes SR-7364 / rdar://problem/39239629 as well as the older
rdar://problem/36278079.
2018-04-20 11:17:21 -07:00
Doug Gregor
8d2ca387ef The test case from rdar://problem/31164540 is also fixed. 2018-04-20 11:15:22 -07:00
Doug Gregor
bb04d87cd8 [AST] Make TypeBase::adjustSuperclassMemberDeclType() more robust.
When performing substitutions in this function, allow them to fail
more gracefully by producing error types. Fixes SR-7457 /
rdar://problem/39492060.
2018-04-20 11:14:50 -07:00
Pavel Yaskevich
26905602f9 Merge pull request #16023 from xedin/rdar-36497404
[Serialization] Refactor normal conformance serialization
2018-04-20 00:05:23 -07:00
Pavel Yaskevich
e1fab0559c [Serialization] Always serialize requirement substitutions
Absence of synthetic generic environment should not affect
serialization of the required substitutions because they can
come from outer requirement context for static members.

Resolves: rdar://problem/36497404
2018-04-19 17:58:13 -07:00
swift-ci
f45a9c8052 Merge pull request #16030 from lorentey/array-hash-encoding 2018-04-19 16:59:02 -07:00
Michael Ilseman
46b88ed906 Merge pull request #15928 from milseman/boilerplate_generated
[test] De-gyb stdlib unittest.
2018-04-19 16:25:00 -07:00
Slava Pestov
6f65d3d0a2 compiler_crashers_2/0153-rdar39130543.swift requires asserts 2018-04-19 14:09:56 -07:00
Michael Ilseman
c4614a9208 [test] De-gyb stdlib unittest.
StdlibUnittest uses gyb to avoid duplicating many source-context
arguments. However, this means that any test that wishes to add new
expect helpers has to also be gybbed. Given that this structure hasn't
changed in years, and we should have a real language support
eventually, de-gyb it.
2018-04-19 13:06:14 -07:00
Karoy Lorentey
882462ff8a [stdlib] Array._hash(into:): Include the count as a discriminator value
This makes the hash encoding unambiguous when arrays are hashed in sequence.
2018-04-19 20:05:29 +01:00
Karoy Lorentey
dffbbd1cda [test] FixedPoint: Fix 32-bit regression 2018-04-18 20:19:59 +01:00
Karoy Lorentey
7e66a38af8 [stdlib] De-gyb SipHash; implement full Hasher API 2018-04-18 17:33:24 +01:00
Karoy Lorentey
ccdc218cbd [stdlib] _Hasher: append => combine 2018-04-18 14:18:44 +01:00
Ben Cohen
ca7aea02e9 [stdlib] Add compatibility typealias for CountablePartialRangeFrom (#15989)
* Add compatibility typealias for CountablePartialRangeFrom
2018-04-17 15:48:54 -07:00
swift-ci
38ba90b181 Merge pull request #15978 from DougGregor/minor-cleanups 2018-04-17 10:48:20 -07:00
Doug Gregor
fec93f991c Add reduced, crashing test case for rdar://problem/39130543. 2018-04-16 11:25:34 -07:00
Robert Widmann
9973b31d5b Skip invalid declarations in SourceLookupCache
Crashers 28598 and 28778 are creating invalid validation requests for the ITC
by using unqualified lookup to get the validator to jump inside of a
transitively invalid DeclContext.

Just don't load these members.
2018-04-16 13:10:34 +02:00