Commit Graph

4740 Commits

Author SHA1 Message Date
Doug Gregor
82ea1dcd39 Merge pull request #15450 from DougGregor/infer-ext-generic-typealias
Retain type sugar for extension declarations that name generic typealiases
2018-03-24 23:57:03 -07:00
Pavel Yaskevich
8375ce9ac0 Merge pull request #15462 from xedin/rdar-35773761
[Diagnostics] Fix a crash when using `withoutActuallyEscaping` incorrectly
2018-03-24 01:03:53 -07:00
Pavel Yaskevich
134f4e5611 [Diagnostics] Fix a crash when using withoutActuallyEscaping incorrectly
Teach `eraseOpenedExistentials` how to handle `OpaqueValueExpr`
associated with `MakeTemporarilyEscapableExpr`.

Resolves: rdar://problem/35773761
2018-03-23 14:41:30 -07:00
Doug Gregor
0c9fb6206c Update one last test for extensions of generic typealiases. 2018-03-23 12:46:36 -07:00
Karoy Lorentey
c196667686 [stdlib] Remove non-obvious conditional Hashable conformances
This removes Hashable conformance for types that do not already implement Equatable:

- CollectionOfOne
- AnyCollection
- DictionaryLiteral
2018-03-23 19:09:28 +00:00
Karoy Lorentey
94e59a3112 [stdlib] Describe availability of new conformances and members
This assumes these will land in Swift 4.1; the attributes need to be adjusted if that turns out not to be the case.

It seems @available for protocol conformances is not yet functional. I added attributes for those anyway, marked with FIXME(conformance-availability).

# Conflicts:
#	stdlib/public/core/ExistentialCollection.swift.gyb
#	stdlib/public/core/Mirror.swift
2018-03-23 19:09:04 +00:00
Nathan Hawes
d6894b82b3 Merge pull request #15247 from nathawes/rdar38144409-code-completion-assertion-hit-in-getTypeOfReference
[code-completion] Fix assertion hit in getTypeOfReference via code completion
2018-03-23 12:08:41 -07:00
Karoy Lorentey
18e7470ae7 [Foundation] NSArray, NSDictionary: Add custom AnyHashable representations
Now that Array and Dictionary conform to Hashable, we need to make sure that their bridged counterparts provide the same hash values when converted to AnyHashable.
2018-03-23 19:08:39 +00:00
Morten Bek Ditlevsen
c9337114d2 [WIP] Conditional conformance to Hashable for Optional, Dictionary and Array types. (#14247)
* Add conditional Hashable conformance to Optional, Dictionary, Array, ArraySlice and ContiguousArray

* Modified hashValue implementations
The hashValues are now calculated similar to the automatically synthesized values when conforming to Hashable.
This entails using _combineHashValues as values of the collections are iterated - as well as calling _mixInt before returning the hash.

* Added FIXMEs as suggested by Max Moiseev

* Use checkHashable to check Hashable conformance

* Use 2 space indentation

* Hashing of Dictionary is now independent of traversal order

* Added a test to proof failure of (previous) wrong implementation of Dictionary hashValue. Unfortunately it does not work.

* Removed '_mixInt' from 'hashValue' implementation of Optional and Array types based on recommendations from lorentey

* Another attempt at detecting bad hashing due to traversal order

* Dictionary Hashable validation tests now detect bad hashing due to dependence on traversal order

* Removed superfluous initial _mixInt call for Dictionary hashValue implementation.

* Add more elements to dictionary in test to increase the number of possible permutations - making it more likely to detect order-dependent hashes

* Added Hashable conformance to CollectionOfOne, EmptyCollection and Range types

* Fix indirect referral to the only member of CollectionOfOne

* Re-added Hashable conformance to Range after merge from master

* Change hashValue based on comment from @lorentey

* Remove tests for conditional Hashable conformance for Range types. This is left for a followup PR

* Added tests for CollectionOfOne and EmptyCollection

* Added conditional conformance fo Equatable and Hashable for DictionaryLiteral. Added tests too.

* Added conditional Equatable and Hashable conformance to Slice

* Use 'elementsEqual' for Slice equality operator

* Fixed documentation comment and indentation

* Fix DictionaryLiteral equality implementation

* Revert "Fix DictionaryLiteral equality implementation"

This reverts commit 7fc1510bc3.

* Fix DictionaryLiteral equality implementation

* Use equalElements(:by:) to compare DictionaryLiteral elements

* Added conditional conformance for Equatable and Hashable to AnyCollection

* Revert "Use 'elementsEqual' for Slice equality operator"

This reverts commit 0ba2278b96.

* Revert "Added conditional Equatable and Hashable conformance to Slice"

This reverts commit 84f9934bb4.

* Added conditional conformance for Equatable and Hashable for ClosedRange
2018-03-23 19:08:38 +00:00
Nathan Hawes
a0cf755528 Update fixed IDE validation-test crasher and move into IDE/crashers_2_fixed 2018-03-22 13:18:36 -07:00
Doug Gregor
3dfd7377ef Merge pull request #15416 from DougGregor/generic-typealias-sugar
[AST] Preserve type sugar for generic typealiases
2018-03-22 13:15:46 -07:00
Slava Pestov
a6ff28285c Sema: Move most of DeclChecker::visitFuncDecl() to validateDecl() 2018-03-21 23:54:48 -07:00
Doug Gregor
e6c91b3985 Start using BoundNameAliasType for non-generic typealiases in generic contexts
Currently, when we reference a (non-generic) typealias within a
generic context, we would completely lose type sugar for the
typealias, replacing it with the underlying type. Instead, use
BoundNameAliasType for this purpose, which allows us to maintain all
of the type sugar as well as storing complete substitutions for later
use.
2018-03-21 23:49:33 -07:00
Slava Pestov
f9f5ebbba9 Sema: Remove DeclChecker::IsSecondPass
The DeclChecker had three possible states:

- IsFirstPass true, IsSecondPass false. This is the 'first pass' for
  declarations that appear at the top-level, or are nested inside
  top-level types.

- IsFirstPass false, IsSecondPass true. This is the 'second pass' for
  declarations that appear at the top-level, or are nested inside
  top-level types.

- IsFirstPass false, IsSecondPass false. This was used for (some)
  local declarations.

This is unnecessarily confusing. We can eliminate the third state
by calling typeCheckDecl() twice in a few places. This allows
IsSecondPass to be removed entirely since it's now always equal to
!IsFirstPass.
2018-03-21 21:41:38 -07:00
Jordan Rose
d150f96967 Merge pull request #14945 from jrose-apple/frozen-enums
Implementation for /most/ of SE-0192 (frozen and non-frozen enums)
2018-03-21 11:06:31 -07:00
Arnold Schwaighofer
3cbabfd196 Merge pull request #15208 from aschwaighofer/resilient_enum_case_tags
IRGen: Make resilient enum's tag indices resilient
2018-03-21 10:21:07 -07:00
David Zarzycki
f5ae7b2584 [validation tests] Improve concurrency
This improves 'ninja check-swift-validation' by about 35% on my Linux desktop.
2018-03-21 09:28:51 -04:00
David Zarzycki
c00c18fc68 [Tests] Consolidate stress/long tests in validation-tests 2018-03-20 22:19:37 -04:00
David Zarzycki
283713d61d [Testing] Formalize stress tests
Stress tests are, by definition, stressful. They intentionally burn a
lot of resources by using randomness to hopefully surface state machine
bugs. Additionally, many stress tests are multi-threaded these days and
they may attempt to use all of the available CPUs to better uncover
bugs. In isolation, this is not a problem, but the test suite as a whole
assumes that individual tests are single threaded and therefore running
multiple stress tests at once can quickly spiral out of control.

This change formalizes stress tests and then treats them like long
tests, i.e. tested via 'check-swift-all' and otherwise opt-in.

Finally, with this change, the CI build bots might need to change if
they are still only testing 'validation' instead of all of the tests.
I see three options:

1) Run all of the tests. -- There are very few long tests left these
   days, and the additional costs seems small relative to the cost of
   the whole validation test suite before this change.
2) Continue checking 'validation', now sans stress tests.
3) Check 'validation', *then* the stress tests. If the former doesn't
   pass, then there is no point in the latter, and by running the stress
   tests separately, they stand a better chance of uncovering bugs and
   not overwhelming build bot resources.
2018-03-20 21:45:28 -04:00
Jordan Rose
9034ba617b Ban @_fixed_layout on enums in favor of @_frozen
In theory there could be a "fixed-layout" enum that's not exhaustive
but promises not to add any more cases with payloads, but we don't
need that distinction today.

(Note that @objc enums are still "fixed-layout" in the actual sense of
"having a compile-time known layout". There's just no special way to
spell that.)
2018-03-20 14:49:10 -07:00
Arnold Schwaighofer
5c827017f8 Add evolution test case for resiliently reordering enum cases 2018-03-20 13:19:56 -07:00
Michael Gottesman
e567bc9028 [+0-all-args] Enable +0 normal arguments.
rdar://34222540
2018-03-19 20:25:31 -07:00
swift-ci
dc3937358a Merge pull request #15353 from graydon/rdar-38631299-only-xfail-when-asserts-are-on 2018-03-19 18:09:48 -07:00
Graydon Hoare
8b8d0a2c6a Restrict a recent XFAILing long_test to assert configurations, rdar://38631299. 2018-03-19 16:00:23 -07:00
Graydon Hoare
7a97691a8d Disable timing-sensitive test that's periodically failing in CI, rdar://38378503. 2018-03-19 13:32:43 -07:00
Karoy Lorentey
7fc1b70fa7 Merge pull request #15239 from lorentey/intentionally-linear
[stdlib] Set, Dictionary: Mix the hash table size into the hash seed
2018-03-19 15:42:20 +00:00
Slava Pestov
fbdd36cda8 Merge pull request #15319 from slavapestov/remove-disable-resilience
Remove build-script flag to disable resilience
2018-03-16 20:37:29 -07:00
David Zarzycki
20d943592e Merge pull request #15244 from davezarzycki/mark_param_passing_tests_as_long_test
[Testing] Mark two latent long tests as 'long_test'
2018-03-16 23:11:09 -04:00
Slava Pestov
694fcddf4e Remove build-script flag to disable resilience 2018-03-16 19:56:17 -07:00
Pavel Yaskevich
9f7d91323b [Sema] Don't allow member type lookup on existential types
Existential types don't support nested types so let's not
allow the lookup to make such access, with only exception
for typealias or associated types without type parameters,
they are currently allowed.

Resolves: rdar://problem/38505436
2018-03-16 13:53:09 -07:00
Chris Eidhof
86fb3faaee [wip] Bool toggle implementation (#14586)
* Bool toggle implementation

* Made it public
2018-03-16 09:17:54 -07:00
Karoy Lorentey
241f006ddc [test] Fix ~10% false pass rate without local hash seeds 2018-03-16 14:58:24 +00:00
Karoy Lorentey
571522e340 Merge pull request #15269 from lorentey/static-snow
[test] Merge hash determinism/randomisation tests
2018-03-16 10:32:51 +00:00
Pavel Yaskevich
4850d54613 Merge pull request #15287 from xedin/rdar-38309176
[CSApply] Don't try to force propagate l-value access in "shallow" mode
2018-03-15 21:23:09 -07:00
Pavel Yaskevich
cdf6cb3f2c [CSApply] Don't try to force propagate l-value access in "shallow" mode
Some of the expressions call into `typeCheckExpressionShallow` while trying to
apply solutions, we need to respect the fact that sub-expressions might be
already properly type-checked while propagating l-value access kind.

Resolves: rdar://problem/38309176
2018-03-15 18:07:51 -07:00
swift-ci
e83018c491 Merge pull request #15277 from lorentey/avalanche 2018-03-15 17:03:37 -07:00
Andrew Trick
afbcbfdfa7 Merge pull request #13071 from glessard/umbp-nonmutating-swapat
nonmutating swapAt implementations for UnsafeMutable(Raw)BufferPointer
2018-03-15 16:35:47 -07:00
Jordan Rose
520d6b9b91 Make NS_TYPED_ENUMS ObjectiveCBridgeable when they wrap an object (#15270)
This allows them to be used in generic arguments for NSArray et al.
We already do this for the ones that wrap bridged values (like
NSString/String), but failed to do it for objects that /weren't/
bridged to Swift values (class instances and protocol compositions),
or for Error-which-is-special.

In addition to this being a sensible thing to do, /not/ doing this led
to IRGen getting very confused (i.e. crashing) when we imported a
Objective-C protocol that actually used an NS_TYPED_ENUM in this way.

(We actually shouldn't be using Swift's IRGen logic to emit protocol
descriptors for imported protocols at all, because it's possible we
weren't able to import all the requirements. But that's a separate
issue.)

https://bugs.swift.org/browse/SR-6844
2018-03-15 16:17:38 -07:00
Karoy Lorentey
05168d7fae [test] Merge hash determinism/randomisation tests 2018-03-15 20:48:39 +00:00
Karoy Lorentey
ec15f7e3e4 [test] Update hash avalanche test
Differentiate between 32-bit and 64-bit inputs. Previously the test was always feeding 64-bit integers to the hasher.
2018-03-15 18:52:44 +00:00
Karoy Lorentey
acfc1b90d4 [test] Test that hashed collections use local hash seeds 2018-03-15 16:30:44 +00:00
David Zarzycki
89b524000b [Testing] Mark two latent long tests as 'long_test'
This improves 'ninja check-swift-validation' performance by about 2.9x
on my Linux desktop. Also, move them to validation-test where the other
long tests live.
2018-03-14 16:17:27 -04:00
swift-ci
1bdf5e41eb Merge pull request #15215 from xedin/rdar-37790062-perf-followup 2018-03-13 14:23:26 -07:00
Pavel Yaskevich
5795215928 [crashers] NFC: Limit time spent in solver for crashers 28684 and 28686 2018-03-13 13:28:58 -07:00
Karoy Lorentey
b0108336f7 Merge pull request #15207 from lorentey/seedless-hashes
[runtime] Add better control over the random hashing seed
2018-03-13 19:46:51 +00:00
Karoy Lorentey
e5eed66b67 [test] Add tests verifying hash randomization. Update tests for new names. 2018-03-13 16:29:43 +00:00
Andrew Trick
bf0463cdc1 Disable Lazy.swift on Ubuntu 16.04.
Even without ASAN this failes with "corrupted double-linked list".

<rdar://problem/35797159> [Associated Type Inference] Swift CI: 1. OSS - Swift ASAN - Ubuntu 16.04 (master) heap-use-after-free ASTContext::getSpecializedConformance llvm::FoldingSetBase::InsertNode
2018-03-13 08:59:51 -07:00
Andrew Trick
725da7f303 Disable Lazy.swift under Linux ASAN.
Waiting for a fix for <rdar://35797159> [Associated Type Inference]
Swift CI: 1. OSS - Swift ASAN - Ubuntu 16.04 (master)
heap-use-after-free ASTContext::getSpecializedConformance
llvm::FoldingSetBase::InsertNode
2018-03-12 15:29:31 -07:00
Joe Groff
3fd2d2165e Merge pull request #15145 from jckarter/trimming-metadata
Trimming metadata
2018-03-12 06:55:59 -07:00
Joe Groff
f01af883fc IRGen: Use known value witness tables for common type layouts.
If a type has the same layout as one of the basic integer types, or has a single refcounted pointer representation, we can use prefab value witness tables from the runtime instead of instantiating new ones. This saves quite a bit of code size, particularly in the Apple SDK overlays, where there are lots of swift_newtype wrappers and option set structs.
2018-03-11 11:04:37 -07:00