Commit Graph

103 Commits

Author SHA1 Message Date
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Mark Lacey
66a11ce66b Revert "[ConstraintSystem] Use semantics providing exprs when dealing with favored types."
This reverts commit 2f80af15ec.

I expected this to have no effect, but it results in one of the
expression type checker tests taking longer, so that test was disabled.

This commit also re-enables the test since it now passes again.
2017-12-02 21:46:31 -08:00
Arnold Schwaighofer
2e99ddec69 Disable test that spuriously fails
SR-6520
2017-12-02 10:37:02 -08:00
Arnold Schwaighofer
d2842b17c0 Disable type_checker_perf fast test
Fails on bot.

SR-6518
2017-12-02 05:43:37 -08:00
Pavel Yaskevich
272fbb4609 [TypeChecker] NFC: Re-enable test-case for rdar://problem/18360240 in resilient builds
Resolves: rdar://problem/35779008
2017-11-30 17:48:47 -08:00
Mark Lacey
3cd9320e93 Merge pull request #13190 from rudkx/adjust-perf-tests
Increase the complexity of a couple type checker perf tests.
2017-11-30 17:17:02 -08:00
Mark Lacey
c7e52922e4 Increase the complexity of a couple type checker perf tests.
Recent changes have made these tests borderline slow, which means they
no longer fail.

Let's make them really slow instead!

(...since they do not scale well, and we cut the actual testing time off at
1s in the solver, which means really slow isn't going to affect test
time much).
2017-11-30 16:00:32 -08:00
Pavel Yaskevich
164baacfa5 [TypeChecker] NFC: Increase polynomial threshold for rdar://18360240 test-case 2017-11-30 15:19:14 -08:00
Arnold Schwaighofer
a69c11978b Disable flaky type_checker_perf test on resilient bot
rdar://35779008
2017-11-30 12:37:11 -08:00
Pavel Yaskevich
97cfcae4a0 [TypeChecker] NFC: Increase exponential threshold for rdar://problem/18360240 test-case 2017-11-29 15:26:02 -08:00
Mark Lacey
8b55a0f61b SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
For Swift 3 / 4:

Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning
and suggesting "!" in places where they are allowed according to
SE-0054.

In places where SE-0054 disallowed IUOs but we continued to accept them
in previous compilers, emit a warning suggesting "Optional" or "?"  as
an alternative depending on context and treat the IUO as an Optional,
noting this in the diagnostic.

For Swift 5:

Treat "ImplicitlyUnwrappedOptional" as an error, suggesting
"!" in places where they are allowed by SE-0054.

In places where SE-0054 disallowed IUOs, emit an error suggestion
"Optional" or "?" as an alternative depending on context.
2017-11-18 11:41:53 +09:00
Pavel Yaskevich
b16add7685 [CSSolver] Prune disjunction choices based on their equivalence class
There are situations where we know equivalence relationship between
multiple disjunctions, let's prune dependent choice space based on
choice picked for the parent disjunction.

Resolves: rdar://problem/35540159
2017-11-16 19:35:14 -08:00
Pavel Yaskevich
66e13bcc85 [ConstraintSolver] Avoid unnecessarily increasing score when matching function types
Remove function-to-function type match score increase, which should only
happen contextually in presence of other restrictions, this used to fix
the case related to matching of arrays of functions with and w/e `throws`
as function parameters which used to be ambigious, and now handled by
collection-upcast conversion score.

Resolves: rdar://problem/35142121
2017-10-31 23:14:35 -07:00
Doug Gregor
9e8023d191 Add slow type-checker test from rdar://problem/35213699. 2017-10-27 23:41:08 -07:00
Mark Lacey
e07a7362cf Add a warning that ImplicitlyUnwrappedOptional is deprecated in 4+.
Per SE-0054, implicitly unwrapped optional is not a distinct type in the
type system, but rather just the notion that certain Optionals (denoted
by the sigil "!" rather than "?") can be implicitly unwrapped.

This is a first step in the direction of implementing this notion by
emitting a warning if the type is spelled out.
2017-10-26 18:09:26 -07:00
Pavel Yaskevich
3b06f2e897 Merge pull request #12072 from xedin/rdar-33429010
[ConstraintGraph] Don't try to contract edge of parameter bindings with `inout` attribute
2017-09-26 11:51:09 -07:00
Pavel Yaskevich
80e4a2226b [ConstraintGraph] Don't try to contract edge of parameter bindings with inout attribute
Currently edge related to the parameter bindings is contracted
without properly checking if newly created equivalence class has
the same inout & l-value requirements. This patch improves the
situation by disallowing contraction of the edges related to parameter
binding constraint where left-hand side has `inout` attribute set.

Such guarantees that parameter can get `inout` type assigned when
argument gets `l-value` type.

Resolves: rdar://problem/33429010
2017-09-22 17:23:12 -07:00
Pavel Yaskevich
3628e5de02 [TypeChecker] Make test-case for rdar://problem/20859567 slightly more complicated
Avoids occasional passes of the performance test which causes CI to fail.
2017-09-21 18:06:36 -07:00
Pavel Yaskevich
f5d72f5eaa [TypeChecker] Mark test-case for rdar://problem/17024694 as "fast"
Changes related to literal binding application improved one of the
type-checker performance test-cases.
2017-09-18 17:27:00 -07:00
Pavel Yaskevich
7d80daf0ff [ConstraintSolver] When ranking bindings prefer type vars with literal bindings
Change the potential binding ranking logic to prefer type variables
which don't have other type variables related to them, but have literal
bindings, over the ones that do have other type variables.
2017-09-15 22:19:39 -07:00
Pavel Yaskevich
0a178fd263 [ConstraintGraph] Disallow subtype constraint contractions
Presently subtype constraint is considered a candidate for contraction
via `shouldContractEdge` when left-hand side of the subtype constraint
is an inout type with type variable inside. Although it's intended to
be used only in combination with BindParam constraint assigned to the
same variable, that is actually never checked and contraction of subtype
constraint like that is invalid.

Resolves: rdar://problem/34333874
2017-09-11 15:13:13 -07:00
Pavel Yaskevich
fcd0069d8d [ConstraintSolver] NFC: Increase default shrinking termination threshold
We've found in practice that multiple different types of expressions
are still going to benefit from shrinking continuing even when it
couldn't simplify up to 10 sub-expressions.
2017-09-08 14:37:20 -07:00
Pavel Yaskevich
98bc9ab970 [TypeChecker] NFC: Adjust "too complex" error position of rdar://problem/20859567 perf test 2017-09-07 22:47:53 -07:00
Mark Lacey
6e7b7f5f18 Update type checker performance tests to use --invert-result.
Also tweak some of the test iteration bounds to ensure we have data
that better fits the models.

Ideally our counter would be a bit better so that those kinds of
tweaks wouldn't be necessary.
2017-08-31 00:25:51 -07:00
Mark Lacey
c63e279966 [Constraint system] Allow the solver to bind collection literal types earlier.
When this kicks in it can result in substantially speeding up type
inference for collection literals.
2017-08-29 00:39:19 -07:00
Mark Lacey
ced386aef3 Move a test that was a bit flaky into the slow tests.
This failed once locally because it was relatively close to 1s for type
checking time, so make it a bit more complex so that it is almost
certain to fail with the current compiler compiled with
release/no-asserts.
2017-08-28 23:58:15 -07:00
swift-ci
85576fe364 Merge pull request #11617 from xedin/constraint-buckets 2017-08-28 16:16:18 -07:00
Pavel Yaskevich
8bf03b5c43 [ConstraintSolver] Add Component class as an isolated "solvable" unit
Move disjunction selection logic one level up from the `solveSimplified`
which allows to simplify its logic and avoid collecting disjunctions
multiple times for each solver step.

Sort constraint components/buckets based on how many disjunctions
they have, that helps to prune some of the branches with incorrect
solutions early which limits overall depth of the search.

Resolves: SR-4714
2017-08-28 13:39:29 -07:00
Graydon Hoare
e90bf12e97 [scale-tests] Adjust for simplex optimizer, which likes more data. 2017-08-26 20:31:15 -07:00
Graydon Hoare
cda91c8779 Add slow typechecker test for rdar 23682605. 2017-08-22 21:25:58 -04:00
swift-ci
52fec3f3f8 Merge pull request #11547 from xedin/perf-33935430 2017-08-21 17:35:35 -07:00
Pavel Yaskevich
ebc2326ea6 Add test-case for rdar://problem/33935430 2017-08-21 16:32:43 -07:00
Mark Lacey
2c9c76f913 One last batch of expression type checker performance test cases. 2017-08-21 10:06:54 -07:00
Mark Lacey
45eaffbf87 More type checker performance tests. 2017-08-18 12:24:30 -07:00
Mark Lacey
3aba55038b Add more type checker performance tests. 2017-08-17 18:40:28 -07:00
Mark Lacey
c076d4bdd5 Move more failing perf tests to the new location. 2017-08-17 14:22:12 -07:00
swift-ci
c0bebc5d12 Merge pull request #11495 from rudkx/add-more-type-checker-perf-tests 2017-08-16 21:55:54 -07:00
Mark Lacey
5178f88924 Move earlier expression type checker performance tests into the new location. 2017-08-16 21:32:42 -07:00
Mark Lacey
8520b579db Merge pull request #11494 from rudkx/add-type-checker-perf-tests
Add type checker performance tests.
2017-08-16 21:32:06 -07:00
Mark Lacey
a133807601 Add type checker performance tests.
Add type checker performance tests under
validation-test/Sema/type_checker_perf.

Under ./fast/ we have tests that compile reasonably quickly now but at
one point did not.

Under ./slow/ we have tests that are still very slow to compile.

Some tests use %scale-test and others
-solver-expression-time-threshold to determine if they are scaling
well or compiling fast enough.

I've got several more tests gathered that have not yet been set up to
run in our test system. Those are forthcoming!

Further contributions welcome.

Thanks go to @xedin who helped collect most of the test cases.
2017-08-16 21:02:50 -07:00
Huon Wilson
10cc96b781 [validation-test] Add some type checker scale-tests. 2017-08-15 17:38:51 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Robert Widmann
71bf312a25 Migrate the rest of the tests to %empty-directory 2017-06-04 11:08:39 -07:00
Pavel Yaskevich
5998cd645f [ConstraintSolver] Penalize conversions from String to UnsafePointer
There are possible situations when we find solutions with String
and String -> UnsafePointer conversions at the same time for
expressions with default string literals. In order to disambiguite
such situations let's prefer solutions without String -> UnsafePointer
conversions if possible.
2017-06-01 14:43:43 -07:00
Pavel Yaskevich
1bc7a1edb9 [ConstraintSolver] Skip generic overloads only if non-generic choices produce higher score solutions
Restrict skipping of the generic overloads only to the situations
when non-generic solution doesn't have any restrictions/fixes, because
there is a possibility that generic overload could produce a better
solution.

Resolves: rdar://problem/32204609.
2017-06-01 14:43:43 -07:00
Mark Lacey
bc7dff5c9f Revert "Re-instate "Improve disjunction selection""
This reverts commit
ecfa406fc5, which was reinstating
3c5b393e0c.

It does not revert one test change from that commit, because
inexplicably one of the tests is still failing, probably due to some
other changes that have happened since. I'm leaving a ticket open to
investigate.

I've added one of the new cases that is failing as a result of this
change.

This is being reverted not because of bugs in this particular commit,
but because it seems to be exposing other bugs in the type checker that
are resulting in source compatibility problems. We need to shake these
other bugs out of the type checker before bringing this change back.
2017-05-15 11:27:11 -07:00
Mark Lacey
ecfa406fc5 Re-instate "Improve disjunction selection"
Thie reinstates 3c5b393e0c, which was
backed out due to it exposing an ambiguous expression in a recent stdlib
commit.
2017-04-29 17:53:13 -07:00
Mark Lacey
1de530e229 Revert "Improve disjunction selection" 2017-04-29 10:45:15 -07:00
Mark Lacey
3c5b393e0c [Constraint solver] Rework how we select the next disjunction to visit.
We previously used a simple heuristic of visiting the disjunction with
the fewest number of elements in it.

Instead, this commit introduces a new way to select the best disjunction
to explore based on attempting disjunctions based on either how much
information we have about the associated type variables (e.g. how many
of the arguments of a function call in the case of bind overload
disjunctions) or by other criteria that help constraint the search or
split the connected components (e.g. coercions and calls to
initializers).

A key part of the improvement here is allowing the type checker to
attempt bindings of types to type variables when there are still
argument conversion constraints between type variables in the
system. The insight here is if there are no other constraints blocking
an attempt to bind types and we have types to try, we will be able to
test those types against active conformance constraints and potentially
fail much earlier while solving.

Visiting disjunctions in a different order exposed some other problems
with the type checker including a couple cases where map is used that
are now considered ambiguous due to problems in how we are ranking
solutions.

I measured an 11-13% reduction in type checking time for the standard
library using a release build of the compiler.
2017-04-28 00:50:16 -07:00
Mark Lacey
e4f19a10c2 [Constraint solver] Type checker perf test with mixed dictionary/closures.
This is now compiling reasonably quickly (rather than "expression was
too complex"), so ensure it does not regress.
2017-04-16 09:45:20 -07:00