Commit Graph

5277 Commits

Author SHA1 Message Date
Michael Ilseman
4111b21cb0 [String] Bug fix for empty-range getCharacters 2018-11-26 12:13:23 -08:00
Karoy Lorentey
5e53e5b144 [test] Set: Add some tests for new index validation features in 5.0 2018-11-23 16:48:32 +00:00
Karoy Lorentey
92d355a4be [test] Dictionary: Add some tests for new index validation features in 5.0 2018-11-23 16:48:23 +00:00
Karoy Lorentey
5d3768d7ff [test] Add more tests for Set.update(with:)
rdar://problem/26013581
2018-11-23 12:50:06 +00:00
Karoy Lorentey
cc3b270691 [test] Set/Dictionary: Restore bucket-level tests for collision handling 2018-11-23 12:49:35 +00:00
Rintaro Ishizaki
5df5711b67 [CodeCompletion] Rework getOperatorCompletions() (#20632)
In postfix completion, for operator completion, we do:

  1. Type check the operand without applying it, but set the resolved
     type to the root of the expression.
  2. For each possible operators:
      i. Build temporary binary/postfix expression
      ii. Perform type checking to see whether the operator is applicable 

This could be very slow especially if the operand is complex.

* Introduce `ReusePrecheckedType` option to constraint system. With
  this option, CSGen respects pre-stored types in expressions and doesn't
  take its sub-expressions into account.
  * Improve type checking performance because type variables aren't
     generated for sub-expressions of LHS (45511835)
  * Guarantee that the operand is not modified by the type checker because
     expression walkers in `CSGen` doesn't walk into the operand.

* Introduce `TypeChecker::findLHS()` to find LHS for a infix operator from
  pre-folded expression. We used to `foldSequence()` temporary
  `SequenceExpr` and find 'CodeCompletionExpr' for each attempt.
  * No need to flatten folded expression after initial type-checking.
  * Save memory of temporary `BinaryExpr` which used to be allocated by
    `foldSequence()`.
  * Improve accuracy of the completion. `foldSequence()` recovers invalid
    combination of operators by `left` associative manner (with
    diagnostics). This used to cause false-positive results. For instance,
    `a == b <HERE>` used to suggest `==` operator. `findLHS()` returns
    `nullptr` for such invalid combination.

rdar://problem/45511835
https://bugs.swift.org/browse/SR-9061
2018-11-22 21:20:51 +09:00
Doug Gregor
d00a7b75c0 Revert "Update Set<AnyHashable> test case that no longer crashes"
This reverts commit 6abc8489ce.
2018-11-21 07:03:19 -08:00
Karoy Lorentey
694b153992 Merge pull request #20643 from lorentey/string-32-simple
[stdlib] _StringObject: Use a full 8-bit discriminator on 32-bit platforms
2018-11-20 17:50:53 +00:00
Graydon Hoare
364be39f2a <rdar://46174386> Restrict CharacterPropertiesLong test to optimized_stdlib configs. 2018-11-19 16:05:20 -08:00
Mark Lacey
df595379ce Move a few more type checker perf tests over to compiling with designated types. 2018-11-17 18:19:44 -08:00
Mark Lacey
256284cf83 Merge pull request #20664 from rudkx/conditionalize-disjunction-selection-on-designated-types
[ConstraintSystem] Enable disjunction ordering change when use of des…
2018-11-17 18:17:55 -08:00
Mark Lacey
a1be08230f [ConstraintSystem] Enable disjunction ordering change when use of designated types are enabled.
We try to work more-or-less bottom up in the expression when we
attempt apply disjunctions first. This is very helpful to get good
results with designated types enabled in the solver. Rather than
forcing tests to specify both `-swift-version 5` (which also enables
this bottom-up behavior) and enabling designated types, allow them to
just enable the later to get the behavior.

We'll eventually have to revisit this when we decide the specific
conditions that we'll enable the use of designated types under.
2018-11-16 22:01:04 -08:00
Slava Pestov
0e1b62dcad SILGen: Don't emit or reference property descriptors for overrides
We want removing a property override to be a resilient change, so
keypaths should not reference them, preferring to reference the
base declaration instead.
2018-11-16 23:18:30 -05:00
Slava Pestov
0a8ee10621 AST: Refactor AbstractStorageDecl::getAccessStrategy() for keypath resilience
Instead of passing in a DeclContext, which we don't have when emitting a keypath
accessor, pass in a ModuleDecl and ResilienceExpansion.

Keypaths now work well enough in inlinable contexts that we can check in an
end-to-end resilience test.
2018-11-16 23:18:30 -05:00
Lance Parker
8306ef322a Merge pull request #20585 from lancep/spotFixForStringCompCrash
[stdlib] properly promote stack buffer to heap buffer when necessary
2018-11-16 19:05:35 -08:00
Mark Lacey
2c15dc2d1c Merge pull request #20625 from rudkx/designated-types-array
[ConstraintSystem] Add Array as a designated type for `+` and `+=`.
2018-11-16 15:28:34 -08:00
Lance Parker
17187344df Make the NormalizationCheck test compare code units 2018-11-16 14:43:04 -08:00
Karoy Lorentey
3b748933f1 [stdlib] _StringObject: Use a full 8-bit discriminator on 32-bit platforms
We now have plenty of extra inhabitants in the variant enum, so we can get rid of the 7-bit hack.

It’d also be possible now to increase small string capacity to a spacious 11 bytes; however this needs a full overhaul of the 32-bit representation, so it needs a little bit more time in the oven.
2018-11-16 18:36:03 +00:00
Lance Parker
12bf2978e3 Michael's feedback 2018-11-16 10:20:46 -08:00
Lance Parker
0009b21533 properly promote stack buffer to heap buffer when necessary 2018-11-16 10:19:48 -08:00
Slava Pestov
55b176f9cd Merge pull request #20627 from slavapestov/add-fixed-crasher
Add validation test for fixed crasher
2018-11-16 10:55:16 -05:00
Mark Lacey
a5d627844a Merge pull request #20618 from rudkx/favor-equality
[ConstraintSystem] When we have multiple conversions/fixes, make equa…
2018-11-16 06:27:42 -08:00
Slava Pestov
c29ae74e4d Add validation test for fixed crasher 2018-11-16 01:43:50 -05:00
Mark Lacey
d7cf830842 [ConstraintSystem] Add Array as a designated type for + and +=.
Also add overloads for these operators to an extension of Array.

This allows us to typecheck array concatenation quickly with
designated type support enabled and the remaining type checker hacks
disabled.
2018-11-15 21:42:33 -08:00
Ben Cohen
1673c12d78 [stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)
* Replace "sanityCheck" with "internalInvariant"
2018-11-15 20:50:22 -08:00
Mark Lacey
347b060322 [ConstraintSystem] When we have multiple conversions/fixes, make equality favored.
This allows us to skip attempting actual conversions.

This speeds up one of our slow test cases, and perturbs the output of
another test. In the latter case, we stop emitting conversions as part
of the non-semantic piece of the array_expr. The fact that we're not
putting conversions in on that path is something I've seen before in
other instances. I'll open a bug if I cannot find one for it, although
I believe it's entirely cosmetic in this case since we don't rely on
the conversion being there.
2018-11-15 18:41:53 -08:00
Slava Pestov
e07dcb6889 Merge pull request #20562 from slavapestov/evolution-symbol-diff
Evolution: Compare symbols before and after
2018-11-15 20:54:54 -05:00
Mark Lacey
33b6e43efa [ConstraintSystem] When we have multiple conversions/fixes, make equality favored.
This allows us to skip attempting actual conversions.

This speeds up one of our slow test cases, and perturbs the output of
another test. In the latter case, we stop emitting conversions as part
of the non-semantic piece of the array_expr. The fact that we're not
putting conversions in on that path is something I've seen before in
other instances. I'll open a bug if I cannot find one for it, although
I believe it's entirely cosmetic in this case since we don't rely on
the conversion being there.
2018-11-15 17:38:22 -08:00
Slava Pestov
5243cc718d Evolution: Compare symbols before and after
A resilient change should not *remove* previously-public symbols.

Note that currently, the test_superclass_properties test does not
meet this critierion, because we always emit keypath property
descriptors, even when the property is an override. Fixing this
is a larger change that I'll address in a follow-on PR, so for now
I'm just going to disable the symbol check for this one test only.

Part of <rdar://problem/40432647>.
2018-11-15 19:55:46 -05:00
Michael Ilseman
f9e6df312a Implement SE-0221: Character Properties (#20520)
Provide convenience properties on Character.
2018-11-15 14:03:49 -08:00
Slava Pestov
517f37088c Evolution: Tweak existing tests to not remove public symbols 2018-11-15 14:55:44 -05:00
Ben Cohen
df2307e035 [stdlib][DNM] Collapse sequence and collection wrappers (#20221)
* Concretize dropFirst/Last/sufix/prefix from Sequence

Remove split customization point

Eliminate SubSequence from Sequence protocol

Collapse LazyCollection

Collapse LazyMapCollection

Eliminate _SequenceWrapper

Collapse LazyFilterCollection

Collapse LazyDrop/PrefixWhileCollection

Fix tests, ABI stability update

Collapse FlattenSequence

* Add entries to source/ABI compatible expected results.

* Update tests to avoid pre-10.14 objc runtime bug

* Expunge _preprocessingPass
2018-11-14 10:05:58 -08:00
swift-ci
4ad727e78f Merge pull request #20565 from rudkx/add-tc-perf-test 2018-11-13 23:20:15 -08:00
Mark Lacey
540968aa12 Add another type checker test for which we're already quite fast. 2018-11-13 22:18:04 -08:00
Joe Groff
32749f331a Merge pull request #20561 from jckarter/multi-payload-xi
Give multi-payload enums extra inhabitants.
2018-11-13 20:41:19 -08:00
Joe Groff
ca402f19b1 Give multi-payload enums extra inhabitants.
Previously, they would forward their unused spare bits to be used by other multi-payload enums, but
did not implement anything for single-payload extra inhabitants.
2018-11-13 18:08:01 -08:00
Maxim Moiseev
74c2da4c4b [xctest] Check for an error message prefix only
Checking the whole message is fragile and might break should the
formatting change ever so slightly.

Fixes: <rdar://problem/46030955>
2018-11-13 14:34:15 -08:00
Erik Eckstein
0b5de45b3f disable the XCTest test to unblock CI
rdar://problem/46030955
2018-11-13 13:56:06 -08:00
swift-ci
c6874bb403 Merge pull request #20512 from harlanhaskins/storage-wars 2018-11-13 13:30:46 -08:00
Max Moiseev
484ff75747 Merge pull request #13698 from apple/revert-12883-disable_modelio_test_ios
Revert "Disable ModelIO test on ios"
2018-11-13 10:57:05 -08:00
Harlan Haskins
66a61c5eca Rename @sil_stored to @_hasStorage 2018-11-12 11:32:32 -08:00
Michael Ilseman
24a95992f9 Merge branch 'master' into uniterator 2018-11-09 15:08:25 -08:00
Michael Ilseman
103861b31f Merge branch 'master' into uniterator 2018-11-09 10:17:05 -08:00
Karoy Lorentey
51be8c7650 [stdib] Remove RandomNumberGenerator._fill(bytes:)
This hidden customization point isn’t used in the stdlib anymore.
2018-11-09 17:37:25 +00:00
Pavel Yaskevich
57122c1a30 Merge pull request #20407 from xedin/contextual-closure-result-mismatch
[CSDiagnostics] Diagnose contextual closure result mismatches via fixes
2018-11-09 00:15:17 -08:00
Michael Ilseman
75943350d2 [String] Give String a custom iterator
Gives us modest wins on complex grapheme strings, but up to 40% on
heavy-ASCII strings.
2018-11-08 18:25:01 -08:00
Slava Pestov
94b1a28011 Fix remaining tests that pass -swift-version 3
Fixes <rdar://problem/45749460>.
2018-11-08 15:48:26 -05:00
Joe Groff
ff7afcdfd7 Give more extra inhabitants to BridgeObject.
The standard library never ended up needing the low extra inhabitants (<4G on 64-bit Darwin,
<4K elsewhere), so BridgeObject can have the same set of extra inhabitants as the other refcounted
types, allowing `String?????` and `Array??????????` to still use optimized representations.
rdar://problem/45881464
2018-11-07 19:03:22 -08:00
Pavel Yaskevich
66a79301b4 [CSDiagnostics] Diagnose contextual closure result mismatches via fixes
Let's keep track of type mismatch between type deduced
for the body of the closure vs. what is requested
contextually, it makes it much easier to diagnose
problems like:

```swift
func foo(_: () -> Int) {}
foo { "hello" }
```

Because we can pin-point problematic area of the source
when the rest of the system is consistent.

Resolves: rdar://problem/40537960
2018-11-07 14:28:50 -08:00
Jordan Rose
bc18397456 [test] Add a fixed crasher test for SR-9199 (#20386) 2018-11-07 09:16:47 -08:00