Commit Graph

672 Commits

Author SHA1 Message Date
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