Commit Graph

119 Commits

Author SHA1 Message Date
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Jordan Rose
eb03f37cba Make sure we infer selectors for accessors when checking a conformance (#14794)
Usually this happens directly, through some use of the class and its
conformance. However, if a conformance is /only/ used to satisfy an
associated type, we seem to bypass the step that actually infers
selector names for accessors, even though we do it successfully for
methods. Fix this by making sure the accessor decls are validated when
a property is, something that normal uses of a property probably have
to do anyway.

Also, simplify inferObjCName by assuming/asserting that it is only
used on things that are already marked @objc.

https://bugs.swift.org/browse/SR-6944
2018-04-02 14:34:00 -07:00
Mark Lacey
ddc671c0c6 Split test case verifying we're no longer exponential type checking tuples.
Split the test case out into multiple validation scale-tests.

Add a new test for 'weak' as well.
2018-03-28 17:08:25 -07:00
Pavel Yaskevich
df1cb55a3b [Sema] Disable long running nil coalescing perf test (rdar://problem/38963783) 2018-03-28 11:19:28 -07:00
Pavel Yaskevich
298bf2aed4 [CSBindings] Cleanup literal binding inference
Don't attempt to store literal bindings directly to `PotentialBindings`
since they might get superseded by non-literal bindings deduced from
other constraints, also don't attempt to check literal protocol conformance
on type variables or member types since such types would always end-up
returning trivial conformance which results in removal of viable literal types.

Resolves: rdar://problem/38535743
2018-03-27 22:51:37 -07:00
Mark Lacey
9385dbb3fb Fix exponential type checking of tuple literals.
This fixes two easy cases where we would go exponential in type
checking tuple literals.

Instead of generating a conversion to a single type variable (which
results in one large constraint system), we generate a conversion ot
the same type that appears in the initializer expression (which for
tuples is a tuple type, which naturally splits the constraint system).

I experimented with trying to generalize this further, but ran into
problems getting it working, so for now this will have to do.

Fixes rdar://problem/20233198.
2018-03-26 14:46:03 -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
Mark Lacey
1aa5e8c925 Disable this test, which is failing in some branches. 2018-02-13 22:19:45 -08:00
Mark Lacey
37009b0d8b [ConstraintSystem] Remove constraint propagation.
The current implementation isn't really useful in the face of generic
overloads. It has never been enabled by default, and isn't useful to
keep around if it is disabled. If we ever want to bring it back,
we know where to look!
2018-02-12 21:30:39 -08:00
Joe Groff
4cffc9fa3f Update validation tests for diagnostic message change from #14391. 2018-02-09 11:56:04 -08:00
Doug Gregor
dee02c42a4 Update test cases for constraint solver performance hack 2018-02-08 22:57:05 -08:00
Doug Gregor
3d32e89e33 [Constraint solver] Favor more-specialized overload among two generics.
When we form an overload set containing two generic functions, where
one is more specialized than the other, "favor" the more-specialized
function in the constraint system so we won't explore any paths
involving the less-specialized function when the more-specialized
version applies. This should be a strict improvement, because
previously we would have always gone down both paths.

Fixes rdar://problem/37371815, taking this exponential example linear.
2018-02-08 20:41:13 -08:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Pavel Yaskevich
fb199ffb92 [TypeChecker] Mark perf test-case for rdar://problem/22282851 as fast
Recent changes to contraction of the closure argument/parameter type
variables resulted in speed up in type-checker performance which resolved
one of existing "slow" test-cases.
2018-02-01 15:27:37 -08:00
Pavel Yaskevich
3b7e555c7e [CSSolver] Fix performance regression related to contraction of closure parameters
Improve situation around closure parameter/argument contractions
by allowing such action if it can be proved that none of the bindings
would result in solver attempting to bind parameter to `inout` type.

Resolves: rdar://problem/36838495
2018-01-31 14:21:14 -08:00
Andrew Trick
dd2e3480e2 Add a test case for AST verification of loaded modules in WMO.
Prior to the following commit, the SILVerifier will assert
on this test case.

PR: 14250 <https://github.com/apple/swift/pull/14250>

commit deebe8b9c7
Author: Andrew Trick <atrick@apple.com>
Date:   Mon Jan 29 15:22:28 2018

    performTypeChecking: Defer verifyAllLoadedModules in WMO mode.
2018-01-30 13:55:08 -08:00
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