Commit Graph

112 Commits

Author SHA1 Message Date
Mark Lacey
e46d2a7216 [Constraint system] Move addPotentialBinding implementation back to CSBdinings.cpp.
The method is logically part of PotentialBindings, but the
implementation doesn't need to live in the header.
2017-09-25 16:52:41 -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
c8fad863c4 [ConstraintSolver] NFC: Refactor PontentialBindings to reference type variable they belong to 2017-09-16 23:35:44 -07:00
Pavel Yaskevich
8c2fa12ac9 [ConstraintSolver] NFC: Move addPotentialBinding into PotentialBindings 2017-09-15 13:31:15 -07:00
Mark Lacey
54f2844acd Merge pull request #11629 from rudkx/bind-param-constraints
Try to ensure we try to bind the elements of BindParam constraints le…
2017-08-25 22:13:52 -07:00
Mark Lacey
a41fa9482f Try to ensure we try to bind the elements of BindParam constraints left-to-right.
If we allow the right-hand type to be bound first, it can artificially
limit the options for the left-hand side, so attempt to delay binding of
the right-hand side types until after we've chosen something for the
left-hand side.

The test here will not fail without this change, but will fail without
this change if the ConstraintGraph.cpp changes from @xedin's edge
contraction patch (https://github.com/apple/swift/pull/11118) are
applied.
2017-08-25 18:00:30 -07:00
Pavel Yaskevich
829ac700a8 [ConstraintSolver] Fix validation of DynamicTypeOf to use left-hand side's representative
When search for potential bindings for the given type variable
encounters `DynamicTypeOf` constraint, its validation should use
representative type variable of the left-hand side instead of
direct comparison.
2017-08-24 18:43:49 -07:00
Pavel Yaskevich
7c9840c204 [ConstraintSolver] When searching for viable bindings treat DynamicTypeOf constraint specially
When trying to find bindings let's avoid type variables which
represent left-hand side of the `DynamicTypeOf` constraint,
 because such type variables might be (implicitly) convertible to
[existential] metatype, but at the same time bound to something else
(e.g. Any), which fails when solver tries to simplify `DynamicTypeOf`
constraint itself.
2017-08-23 18:03:27 -07:00
Robert Widmann
296492e4d1 Merge pull request #10941 from CodaFi/im-in-ur-member-base
Never Bind to ErrorType
2017-07-18 14:14:19 -07:00
Mark Lacey
524b7f2a78 [Constraint system] Properly infer types for collections of vars.
When we saw lvalue- or inout-types we were not appropriately looking at
the underlying types when performing a join. As a result we would infer
Any in cases where we should have inferred a common supertype.

rdar://problem/31127419
2017-07-14 17:12:01 -07:00
Robert Widmann
e3bb2bef64 Prevent potential bindings to ErrorType 2017-07-13 13:22:44 -07:00
Mark Lacey
7cd4102d01 [Constraint system] Begin refactoring type variable binding selection.
Split out the code for selecting potential bindings into a separate file
as a first step before refactoring it for improved clarity and ease of
modification.
2017-07-09 10:29:42 -07:00