Commit Graph

236 Commits

Author SHA1 Message Date
Pavel Yaskevich
54406b49de [ConstraintSystem] Track constraints that caused bindings to be "fully bound"
- Keep track of all constraints which caused a particular type variable to
  be de-prioritized.

- Convert a property to a method which would determine whether
  given set of potential bindings is "fully bound" and has to
  be delayed until certain constraints are simplified.
2020-12-04 21:50:04 -08:00
Frederick Kellison-Linn
a53b1e4f3f [Sema] Always look through optionals for unresolved member lookup 2020-12-04 12:11:10 -05:00
Pavel Yaskevich
96415b237e [CSBinding] Attempt to join any existing and viable bindings with new binding
Instead of attempting to join only the last recorded supertype
binding, let's attempt to join any previously recorded supertype
binding with an incoming one to make sure that set contains only
the most viable types.
2020-11-19 18:06:35 -08:00
Nathan Hawes
1eb05b7760 Merge pull request #34733 from nathawes/migrate-unresolved-completion
[CodeCompletion][Sema][Parse] Migrate unresolved member completion to the solver-based completion implementation
2020-11-19 01:26:43 -08:00
Nathan Hawes
86ddd52204 [Sema] Extract out expression-contains-completion-loc check into a method on ConstraintSystem (NFC) 2020-11-19 09:32:38 +11:00
Pavel Yaskevich
094ca8077d Merge pull request #34737 from xedin/potential-bindings-refactor
[ConstraintSystem] Infer some of the bindings attributes on demand
2020-11-16 13:28:21 -08:00
Pavel Yaskevich
afa11989c9 [ConstraintSystem] Determine whether bindings are potentially incomplete on demand 2020-11-13 13:45:58 -08:00
Pavel Yaskevich
6a7cc79f83 [ConstraintSystem] Determine whether type variable is a hole on demand 2020-11-11 15:31:24 -08:00
Pavel Yaskevich
4ed9794547 [ConstraintSystem] Compute whether bindings are bound only by existentials on demand 2020-11-11 14:19:49 -08:00
Pavel Yaskevich
7f228b0e31 [ConstraintSystem] Compute # of defaultable bindings on demand 2020-11-11 12:35:53 -08:00
Slava Pestov
0ff82ca051 Sema: Check conformance availability when ranking solutions
This completes the work on <rdar://problem/35158274>, and also
adds a test case for <rdar://problem/50627401>.
2020-11-10 17:52:51 -05:00
Holly Borla
a647f0fb5b Merge pull request #34399 from hborla/optimize-linked-operator-solving
[Constraint System] Implement heuristics for linked operator expressions in the solver proper.
2020-11-08 13:22:40 -08:00
Doug Gregor
33cfbbdd72 [Concurrency] Don't diagnose missing "self." in async let autoclosures. 2020-11-04 23:18:51 -08:00
Holly Borla
b9e08b23fb [ConstraintSystem] Allow the solver to find other solutions after
successfully finding a solution by favoring operators already bound
elsewhere.

Favoring existing operator bindings often lets the solver find a solution
fast, but it's not necessarily the best solution.
2020-10-29 14:33:29 -07:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
swift-ci
b654008443 Merge pull request #34337 from nathawes/allow-missing-args-when-type-checking-for-completion 2020-10-19 15:26:50 -07:00
Pavel Yaskevich
59e8043cb9 Merge pull request #34278 from xedin/transitive-protocol-inference
[CSBindings] Implement transtive protocol requirement inference
2020-10-19 13:29:40 -07:00
Nathan Hawes
15f5222bbd [CodeCompletion][Sema] Allow missing args when solving if the completion location indicates the user may intend to write them later.
func foo(a: Int, b: Int) {}
func foo(a: String) {}

// Int and String should both be valid, despite the missing argument for the
// first overload since the second arg may just have not been written yet.
foo(a: <complete here>

func bar(a: (Int) -> ()) {}
func bar(a: (String, Int) -> ()) {}

// $0 being of type String should be valid, rather than just Int, since $1 may
// just have not been written yet.
bar { $0.<complete here> }
2020-10-19 12:16:19 -07:00
Luciano Almeida
907b06901f Merge pull request #34330 from LucianoPAlmeida/SR-13732-crash-invalid
[SR-13732] [Sema] Fix crash on simplifyFix constraint for tuple mismatch
2020-10-16 21:18:22 -03:00
Luciano Almeida
883d583a2f [CSSimplify] Make sure visit and record holes recursivelly for dependent member type 2020-10-16 18:32:20 -03:00
Pavel Yaskevich
5dc9919aff [ConstraintSystem] NFC: Make SemaTest a friend of ConstraintSystem
This is necessary in order to have access to private members of
a `ConstraintSystem` for testing purposes, such as logic related
to potential binding computation.
2020-10-15 16:27:35 -07:00
Pavel Yaskevich
d011bf3d7d [CSBindings] Implement transtive protocol requirement inference
Implements iterative protocol requirement inference through
subtype, conversion and equivalence relationships.

This algorithm doesn't depend on a type variable finalization
order (which is currently the order of type variable introduction).

If a given type variable doesn't yet have its transitive protocol
requirements inferred, algorithm would use iterative depth-first
walk through its supertypes and equivalences and incrementally
infer transitive protocols for each type variable involved,
transferring new information down the chain e.g.

  T1   T3
   \   /
    T4    T5
     \    /
       T2

Here `T1`, `T3` are supertypes of `T4`, `T4` and `T5`
are supertypes of `T2`.

Let's assume that algorithm starts at `T2` and none of the involved
type variables have their protocol requirements inferred yet.

First, it would consider supertypes of `T2` which are `T4` and `T5`,
since `T5` is the last in the chain algorithm would transfer its
direct protocol requirements to `T2`. `T4` has supertypes `T1` and
`T3` - they transfer their direct protocol requirements to `T4`
and `T4` transfers its direct and transitive (from `T1` and `T3`)
protocol requirements to `T2`. At this point all the type variables
in subtype chain have their transitive protocol requirements resolved
and cached so they don't have to be re-inferred later.
2020-10-15 16:27:35 -07:00
Pavel Yaskevich
a9cce605a4 [CSBindings] Shrink binding "sources" to supertype and equivalence only
Instead of recording all of the binding "sources" let's only record
subtype, supertype and equivalence relationships which didn't materialize
as bindings (because other side is a type variable).

This is the only information necessary to infer transitive bindings
and protocol requirements.
2020-10-15 16:27:35 -07:00
Pavel Yaskevich
0c51159228 [CSBindings] Record constraint associated with a subtype relationship
While inferring bindings, let's record not only the fact that current
type variable is a subtype of some other type variable but track
constraint which establishes this relationship.
2020-10-15 16:27:35 -07:00
Pavel Yaskevich
17f7ad82ca [CSBindings] Record all of the protocol requirements (not just literal) 2020-10-15 16:27:35 -07:00
gregomni
ab6d92b1cd Favor operators based on existing binds via both basename and type 2020-10-15 09:03:45 -07:00
Holly Borla
c84bd00819 [ConstraintSystem] Move getResolvedOverloads() from CSStep to ConstraintSystem. 2020-10-15 09:03:45 -07:00
Holly Borla
529660d2c9 Merge pull request #34315 from hborla/remove-operator-designated-types
[ConstraintSystem] Remove implementation of operator designated types in the solver.
2020-10-15 09:02:09 -07:00
Holly Borla
4c0f49f7a6 [ConstraintSystem] Remove selectApplyDisjunction, which was only used
by the operator designated types implementation.
2020-10-14 17:28:33 -07:00
Holly Borla
1e0038c3be [ConstraintSystem] Remove implementation of operator designated types
in the solver.
2020-10-14 16:05:54 -07:00
Robert Widmann
6125d25cb4 [NFC] Silence Non-Exhaustive Switch Warnings on Windows 2020-10-14 13:26:09 -07:00
Pavel Yaskevich
6a19d37166 Merge pull request #34286 from xedin/add-sema-unittest-fixture
[unittests] Add a fixture for Sema unit tests
2020-10-14 00:33:34 -07:00
Pavel Yaskevich
2d6456c03e [ConstraintSystem] NFC: Remove obsolete getPotentialBindings declaration
It has been related with `inferBindingsFor` but declaration was
left in the header.
2020-10-13 01:22:09 -07:00
Pavel Yaskevich
dc7c9c2bfa [unittests/Sema] Add a simple integer literal type inference test 2020-10-12 18:57:20 -07:00
Pavel Yaskevich
461eafff54 [ConstraintSystem] NFC: Move ConstraintSystem.h to include/swift/Sema 2020-10-08 10:45:47 -07:00