Commit Graph

5277 Commits

Author SHA1 Message Date
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
Jordan Rose
93fb20fcbc Add a test for SR-8209, which seems to be fixed (#17838)
https://bugs.swift.org/browse/SR-8209
2018-07-10 14:09:58 -07:00
Jordan Rose
d4668833e0 [Driver] Only link to compiler_rt if present for the target platform
Tweak the tests to check this correctly.
2018-07-10 12:45:59 -07:00
Karoy Lorentey
ea98396dbd [test] Skip two Dictionary tests to unblock CI 2018-07-10 13:13:59 +01:00
Jordan Rose
64b3d88d93 [Driver] Always link compiler_rt on Darwin
Turns out it's needed for normal builtins that can appear in inlinable
functions, including Objective-C's @available. Clang always links it
unconditionally, so so should Swift.

Note that this does mean you have to build compiler_rt to get a
successful test run on Apple platforms. That was always true if you
wanted the sanitizer tests to work, though.

rdar://problem/41911599
2018-07-09 13:42:02 -07:00
Pavol Vaskovic
b7eb476f94 [benchmark] Moved tests for benchmark scripts
Moved `lit` test that runs unit tests for benchmark scripts from `validation-test/Python` to `test/benchmark` directory. Run the tests for benchmark infrustructure with single lit invocation:
````
swift-source$ ./llvm/utils/lit/lit.py -sv ${SWIFT_BUILD_DIR}/test-macosx-x86_64/benchmark
````

Documented the invocation of benchmark infrastructure tests in README.md
2018-07-09 13:55:48 +02: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
Slava Pestov
381483bd74 AST: Remove Expr's LValueAccessKind 2018-07-05 23:54:13 -07: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
swift-ci
003ec25cfa Merge pull request #17742 from lorentey/nsdictionary-speedup 2018-07-05 12:19:30 -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
Doug Gregor
f4359b73f9 Merge pull request #17729 from DougGregor/minimize-override-checking
[Type checker] Minimize checking needed to compute the set of overridden declarations
2018-07-05 06:38:46 -07: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
Slava Pestov
a78209610c Add test case for crasher that's already fixed on master 2018-07-04 00:42:33 -07:00
Doug Gregor
7279eeeeac [Type checker] Perform more minimal checking in resolveOverriddenDecl().
Rather than deferring to the heavyweight validateDeclForNameLookup()
to perform the “get overridden decls” operation, perform a much more
minimal validation that only looks for exact matches when the ‘override’
modifier is present.

The more-extensive checking (e.g., that one didn’t forget an override
modifier) is only performed as part of the “full” type checking of
a declaration, which will typically only be done within the same source
file as the declaration. The intent here is to reduce the amount of
work performed to check overrides cross-file, and limit the dependencies
of the “get overridden decls” operation.
2018-07-03 17:26:38 -07:00
Slava Pestov
308463af38 Add test case for bug that's already fixed 2018-07-03 16:03:07 -07:00
Slava Pestov
28b0606b46 'Migrate' compiler crashers to Swift 4 2018-07-03 16:03:07 -07:00
Slava Pestov
80232e8c49 Resolve a disabled compiler crasher fixed by my recent inheritance clause changes
Fixes <rdar://problem/38932729>.
2018-07-03 15:42:31 -07:00
Pavel Yaskevich
55eb35c0f9 Merge pull request #17669 from xedin/rdar-40722855
[Parser] Make sure to add implicit parens to call for prefix/postfix operators when needed
2018-07-03 11:01:27 -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
Pavel Yaskevich
2ce5ae34c1 [Parser] Make sure to add implicit parens to call for prefix/postfix operators when needed
Currently when call involving prefix/postfix operator is formed we
don't wrap argument in implicit parens (like we do with other calls)
when user didn't provide any explicitly, this is bad because
argument-to-parameter matcher requires multiple special cases to handle
such behavior, so let's start wrapping arguments in implicit parens instead.

Resolves: rdar://problem/40722855
Resolves: [SR-7840](https://bugs.swift.org/browse/SR-7840)
2018-07-02 06:07:15 -07:00
Mark Lacey
0a46b4b040 Merge pull request #17663 from rudkx/adjust-test-complexity
Adjust several type checker perf tests to be more complex.
2018-07-01 17:30:52 -07:00
Mark Lacey
8d980c9616 Adjust several type checker perf tests to be more complex.
None of these failed naturally based on the limits of the "too
complex" heuristic and several were relatively closer to the time-out
threshold used in the test RUN line.

Increasing the complexity will ensure that we don't see spurious
failures on builders or on local machines.
2018-07-01 14:41:49 -07:00
swift-ci
d02411f84b Merge pull request #17655 from rudkx/move-slow-test 2018-06-30 18:01:31 -07:00
Mark Lacey
a4068663ba This test case isn't really fast, and failed a few times for me locally.
Make it more complex to ensure that it fails consistently in the slow
directory.
2018-06-30 11:25:44 -07:00
John McCall
f81036202d Merge pull request #17566 from rjmccall/storage-impls
Generalize storage implementations to support generalized accessors
2018-06-30 12:58:33 -04:00
John McCall
9bee3cac5a Generalize storage implementations to support generalized accessors.
The storage kind has been replaced with three separate "impl kinds",
one for each of the basic access kinds (read, write, and read/write).
This makes it far easier to mix-and-match implementations of different
accessors, as well as subtleties like implementing both a setter
and an independent read/write operation.

AccessStrategy has become a bit more explicit about how exactly the
access should be implemented.  For example, the accessor-based kinds
now carry the exact accessor intended to be used.  Also, I've shifted
responsibilities slightly between AccessStrategy and AccessSemantics
so that AccessSemantics::Ordinary can be used except in the sorts of
semantic-bypasses that accessor synthesis wants.  This requires
knowing the correct DC of the access when computing the access strategy;
the upshot is that SILGenFunction now needs a DC.

Accessor synthesis has been reworked so that only the declarations are
built immediately; body synthesis can be safely delayed out of the main
decl-checking path.  This caused a large number of ramifications,
especially for lazy properties, and greatly inflated the size of this
patch.  That is... really regrettable.  The impetus for changing this
was necessity: I needed to rework accessor synthesis to end its reliance
on distinctions like Stored vs. StoredWithTrivialAccessors, and those
fixes were exposing serious re-entrancy problems, and fixing that... well.
Breaking the fixes apart at this point would be a serious endeavor.
2018-06-30 05:19:03 -04:00
Slava Pestov
1d2d653844 IDE: Redo typeCheckContext()
- Don't type check top-level contexts multiple times
- Use validateDecl() instead of typeCheckDecl() when possible
2018-06-30 00:20:37 -07:00
Doug Gregor
e7ee53b6e0 Merge pull request #17622 from DougGregor/fix-optional-rethrows-checking
[Type checker] Look through optionals when checking for rethrows.
2018-06-29 10:22:41 -07: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
Doug Gregor
932e9bef2f [Type checker] Look through optional injections when checking for rethrows.
Fixes SR-5427.
2018-06-29 09:35:01 -07: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
Jordan Rose
f1b347c0cc Handle non-deserializable SIL functions referenced in witness tables
This is enough to let the test case in rdar://problem/40899824 pass,
and any callers of this function already need to be able to handle a
nullptr result. There's a lot more work to do in this area, but it's
nice to get the simple things working again.
2018-06-27 17:24:22 -07:00
Jordan Rose
8ea96e95c6 [test] Add minimized test case from SR-7337 (#17524)
Because we've changed how conformances represent associated types
since Swift 4.2 branched, the error described there no longer occurs.
But we still want to make sure we don't regress.

https://bugs.swift.org/browse/SR-7337
2018-06-26 14:31:01 -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
Huon Wilson
c6acfbbe3a Merge pull request #17286 from AnthonyLatsis/remove-replacement-of-invalid-Self
[Sema] Don't replace invalid Self with the context type
2018-06-25 10:10:39 +10:00
swift-ci
6ed6b2fd9b Merge pull request #17408 from airspeedswift/one-is-the-loneliest-iterator 2018-06-22 11:54:26 -07:00
Anthony Latsis
092666526c Update fixed crasher validation test 2018-06-22 05:23:15 +03:00
Ben Cohen
2eec236f13 Move two more Iterators into nested types 2018-06-21 16:28:20 -07:00
Jordan Rose
15c0ca5642 [test] Work around an issue with Apple's internal bots (#17397)
rdar://problem/41332918
2018-06-21 11:33:12 -07:00
Slava Pestov
e07aefbe74 stdlib: Add -swift-version 3 to two more tests 2018-06-20 22:55:38 -07:00
Huon Wilson
92189c6079 Merge pull request #17356 from huonw/lazier-conditional-requirements
More errors instead of crashes for conditional conformances that are invalid or involve hard-to-resolve recursion
2018-06-21 11:59:49 +10:00
Huon Wilson
a21a7798d8 [Sema] Be more resilient about unavailable conditional requirements in error cases.
When we're trying to diagnose something, it's a bad look if we crash
instead. This changes the bad-associated-type recovery path to not require that
the conditional requirements have been computed, and instead detects that as a
possible error.

Fixes https://bugs.swift.org/browse/SR-8033.
2018-06-21 10:53:30 +10:00