Commit Graph

561 Commits

Author SHA1 Message Date
Mark Lacey
e17898c70a Revert a type checker perf test that apparently is still not consistently fast enough. 2018-10-04 15:48:22 -07:00
Mark Lacey
1f517d328d [ConstraintSystem] Distinguish between overloads from a type vs. an extension.
For operators with default implementations in an extension, we don't
want to typecheck it both with overloads from the protocol type and
the ones from the extension.
2018-10-03 18:51:43 -07:00
Mark Lacey
48c6cb40cf Fix release-build test failure due to unaccounted-for warning. 2018-10-03 16:53:04 -07:00
Mark Lacey
472d333a1b Test updates for -solver-enable-operator-designated-protocols.
These are cases that I know are faster when this is enabled. The test
updates all additionally disable the existing performance hacks as
well as the shrink phase of the solver.
2018-10-03 16:01:59 -07:00
Mark Lacey
1d227731c1 [ConstraintSystem] Only use the new disjunction ordering under -swift-version 5.
This will minimize the chance of breaking code. Currently SwiftLint
has one "too complex" expression with this change. Further changes to
the solver may improve that situation, and potentially allow us to
move this out from -swift-version 5 if we're willing to take the risk
of breaking some code as a result.
2018-09-26 14:55:07 -07:00
Mark Lacey
c6c66f6873 [ConstraintSystem] Change the order in which we visit disjunctions.
Attempt to visit disjunctions that are associated with applies where
we have at least some useful information about the types of all of the
arguments before visiting other disjunctions.

Two tests here got faster, and one slightly slower. One of the
faster tests is actually moving from test/ to the slow/ directory in
validation-test because despite going from 16s to less than 1s, it was
still borderline for what we consider the slow threshold, so I made
the test more complex. The one that got a little slower is
rdar22022980, which I also made more complex so that it is clearly
"slow" by the way we are testing it.

slower:
  rdar22022980.swift

faster:
  rdar33688063.swift
  expression_too_complex_4.swift
2018-09-20 13:15:59 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Pavel Yaskevich
a69c6e2964 [CSBindings] Don't record duplicate bindings for opened nominal types
Otherwise it would result in checking the same type multiple times
and results in worse pontential binding picks.
2018-08-30 18:15:55 -07:00
Pavel Yaskevich
f110942097 Merge pull request #19066 from xedin/try-typevar-bindings-cleanup
[CSBindings] Cleanup `tryTypeVariableBindings`
2018-08-30 16:12:51 -07:00
Jordan Rose
296afc7773 [test] Add a test for SR-8493, so we don't regress (#19068)
https://bugs.swift.org/browse/SR-8493
2018-08-30 11:13:01 -07:00
Pavel Yaskevich
2ae8e8d0cb [CSBindings] Cleanup tryTypeVariableBindings
* Move logic to ensure that r-value type var would get r-value type to `PotentialBindings`;
* Strip uncessary parens directly when creating `PotentialBinding`;
* Check if the binding is viable before inclusion in the set, instead of filtering it later;
* Assert that bindings don't have types with errors included in the set.
2018-08-30 00:08:26 -07:00
Ben Cohen
83823f5f7f [stdlib] Obsolete various compatibility shims in 5.0 (#19008)
* Obsolete ModifierSlice typealiases in 5.0

* Obsolete *Indexable in 5.0

* Obsolete IteratorOverOne/EmptyIterator in 5.0

* Obsolete lazy typealiases in 5.0

* Drop .characters from tests

* Obsolete old literal protocols in 5.0

* Obsolete Range conversion helpers in 5.0

* Obsolete IndexDistance helpers in 5.0

* Obsolete Unsafe compat helpers in 5.0

* Obsolete flatMap compatibility helper in 5.0

* Obsolete withMutableCharacters in 5.0

* Obsolete customPlaygroundQuickLook in 5.0

* Deprecate Zip2Sequence streams in 5.0

* Replace * with swift on lotsa stuff

* Back off obsoleting playground conformances for now
2018-08-28 13:20:25 -07:00
Arnold Schwaighofer
b9fe52ed13 Codesign validation-test/Sema/rdar32204609.swift 2018-08-13 08:32:58 -07:00
Pavel Yaskevich
65e67034f8 Merge pull request #18550 from xedin/improve-conformance-req-diags
[Diagnostics] Improve missing conformance diagnostics by using affect…
2018-08-08 00:36:40 -07:00
Pavel Yaskevich
ba085e5bdc [Diagnostics] Improve missing conformance diagnostics for sub-types and members
If generic parameter associated with missing conformance comes
from different context diagnose the problem as "referencing" a
specific declaration from affected type.
2018-08-07 18:55:43 -07:00
Mark Lacey
11eaf7db64 Disable test that seems to be flaky at the moment. 2018-08-07 16:00:08 -07:00
Pavel Yaskevich
ad171e05cc [Diagnostics] Improve missing conformance diagnostics by using affected declaration
Instead of simply pointing out which type had conformance failures,
let's use affected declaration instead, which makes diagnostics much
richer e.g.

```
'List<[S], S.Id>' requires that 'S.Id' conform to 'Hashable'
```

versus

```
initializer 'init(_🆔)' requires that 'E' conform to 'Hashable' [with 'E' = 'S.Id']
```

Since latter message uses information about declaration, it can also
point to it in the source. That makes is much easier to understand when
problem is related to overloaded (function) declarations.
2018-08-07 12:59:53 -07:00
Pavel Yaskevich
c2bf3d5ba9 [TypeChecker] NFC: Fix all of the diagnostics improved by conformance tracking 2018-08-02 21:55:16 -07:00
Mark Lacey
9a3e282066 Temporarily disable performance test that is 'failing' by running too fast.
I am reworking these to be based on the scope counter rather than a
timer.

rdar://problem/42744631
2018-07-30 15:44:37 -07:00
Pavel Yaskevich
ae4e106491 Merge pull request #18281 from xedin/gather-constraints-improvements
[Perf Experiment][ConstraintGraph] Gather constraints improvements
2018-07-28 00:27:36 -07:00
Doug Gregor
fa9a24538f [Standard library] Ascribe types to some literals to improve typecheck time.
One expression in the new hashing implementation is going exponential,
accounting for a huge amount of type-checking type. Add (admittedly ugly)
“as UInt64” annotations to greatly reduce the time to type-check this
expression.

*Ahem* type-checking time for the standard library goes from 24s->14s with
this change. Added a type-checker “slow” performance test and captured
the problem in rdar://problem/42672946.
2018-07-27 14:10:49 -07:00
Pavel Yaskevich
dd798accd8 [ConstraintGraph] Use set to gather constraints for type variables
Since it's possible to find the same constraint through two different
but equivalent type variables, let's use a set to store constraints
instead of a vector to avoid processing the same constraint multiple
times.
2018-07-26 22:41:07 -07:00
Michael Gottesman
be568902f2 [ownership] Always print out ownership argument annotations whether or not -enable-sil-ownership is passed in.
This is how we originally controlled whether or not we printed out ownership
annotations when we printed SIL. Since then, I have changed (a few months ago I
believe) the ownership model eliminator to know how to eliminate these
annotations from the SIL itself. So this hack can be removed.

As an additional benefit, this will let me rename -enable-sil-ownership to
-enable-sil-ownership-verifier. This will I hope eliminate confusion around this
option in the short term while I am preparing to work on semantic sil again.

rdar://42509812
2018-07-24 13:18:37 -07:00
Mark Lacey
c0007f8168 Revert "[ConstraintSystem] Fix the ordering of functions with optional parame…" 2018-07-19 00:21:12 -07:00
Pavel Yaskevich
e1ab6da7a9 [TypeChecker] NFC: Make test-case for rdar://problem/33688063 more complicated
SE-0213 improved cases like that but we still have problem with operator
overloads, so just need to make this a bit more complicated to reproduce again.

Resolves: rdar://problem/42304000
2018-07-18 17:02:20 -07:00
Mark Lacey
eca92003bc Merge pull request #17855 from rudkx/rdar19748710
[ConstraintSystem] Fix the ordering of functions with optional parame…
2018-07-18 14:31:17 -07:00
Mark Lacey
d271f4b057 [ConstraintSystem] Ensure we prefer f(_: Any) to f(_: Any?) when both work.
...unless the argument is an `Any?`, in which case we prefer `f(_: Any?)`.

This change also results in our selecting f<T>(_: T) over f(_:
Any). Coercing with 'as Any' makes it possible to explicitly select
the Any overload. Previously there was no way to select the generic
overload.
2018-07-18 11:44:04 -07:00
Pavel Yaskevich
aa9b3d8474 [TypeChecker] SE-0213: Implement literal init via coercion
Implementation is as follows: In `preCheckExpression` try to
detect if there is `T(literal)` call in the AST, replace it with
implicit `literal as T`, while trying to form type-checked AST,
after constraint solving, restore source information and drop
unnecessary coercion expression.

Resolves: rdar://problem/17088188
Resolves: rdar://problem/39120081
Resolves: rdar://problem/23672697
Resolves: rdar://problem/40379985
2018-07-17 12:08:59 -07:00
Matt Diephouse
35592747db Change "enum element" to "enum case" in diagnostics
From the perspective of the compiler implementation, they're elements. But users will think of these as cases—and many diagnostics already refer to these as enum cases.
2018-07-15 16:01:10 -04: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
Slava Pestov
28b0606b46 'Migrate' compiler crashers to Swift 4 2018-07-03 16:03:07 -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
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
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
Mark Lacey
40b4eda258 Merge pull request #17352 from rudkx/reenable-perf-hack-attempt-2
[ConstraintSystem] Reinstate favoring more specialized of two generic…
2018-06-20 16:52:30 -07:00
Mark Lacey
1a2d7f5e99 [ConstraintSystem] Reinstate favoring more specialized of two generic overloads.
This was originally commited in
3d32e89e33, and then backed out in
c40fd3966c due to concern over
behavioral changes.

This version avoids the optimization when there are any optional types
involved in the signatures of the functions.

For these cases, compareDeclarations can return the wrong order at the
moment.

I have another PR in the works that attempts to begin unraveling some
of the issues around fixing the overload comparisons.
2018-06-19 23:42:51 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Mark Lacey
c40fd3966c [ConstraintSystem] Remove an unsound optimization hack for generic functions.
I think there is something far more narrow we could do here, but I'm
not sure if there is real code that such a hack would benefit from. We
can leave that to consider another day.

Fixes rdar://problem/40819547 (aka https://bugs.swift.org/browse/SR-7884).
2018-06-06 23:59:08 -07:00
Mark Lacey
b92649a013 [ConstraintSystem] Attempt to select disjunctions that split constraint systems.
When selecting the next disjunction to attempt, try to find one that
is a disjunction of bindings where the type being bound is the
converted-to type in a conversion constraint. Attempting these early
makes it possible to split constraint systems, eliminating exponential
behavior.

Fixes: rdar://problem/40344044
2018-05-23 16:52:43 -07:00
Mark Lacey
35cd6023b4 Add a test case for which we currently end up with exponential type checking. 2018-05-22 23:41:31 -07:00
Pavel Yaskevich
3e254678a2 [Sema] Add counter to track number of constraints considered by each edge contraction attempt 2018-05-12 02:37:52 -07:00
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