Commit Graph

21 Commits

Author SHA1 Message Date
Pavel Yaskevich
d7984f4453 [ConstraintSystem] Attempt conjunction before closure result or generic parameter holes
Closure result type or generic parameter associated with such a location
could bw inferred from a body of a multi-statement closure (when inference
is enabled), so we need to give closure a chance to run before attemtping
a hole for such positions in diagnostic mode.
2021-12-03 10:57:42 -08:00
Pavel Yaskevich
bc54bc6bb7 Revert "[TypeChecker] SE-0326: Enable multi-statement closure inference by default" 2021-11-29 17:26:08 -08:00
Pavel Yaskevich
aa3b8867a3 [ConstraintSystem] Attempt conjunction before closure result or generic parameter holes
Closure result type or generic parameter associated with such a location
could bw inferred from a body of a multi-statement closure (when inference
is enabled), so we need to give closure a chance to run before attemtping
a hole for such positions in diagnostic mode.
2021-11-15 16:42:06 -08:00
Pavel Yaskevich
cf13e292e7 [CSBindings] Account for literal bindings when checking "subtype of existential" property
It's important to know whether a binding set has all of its bindings
as subtypes of some existential type(s), type variables like that
should be delayed.

Incremental binding inference introduced a bug into computation of
this property by checking only directly inferable bindings, but
it's also important to check that there are no literal requirements
that can produce bindings, because that would mean that type variable
can never be just a subtype of existential type(s).

Resolves: rdar://77570994
2021-05-26 10:10:35 -07:00
Pavel Yaskevich
dd1b8b3224 [CSBindings] Fix merge conflicts with main 2021-02-24 10:38:31 -08:00
Pavel Yaskevich
10df9d23ff [CSBindings] An attempt to make isViable filter out duplicate bindings 2021-02-24 10:38:31 -08:00
Pavel Yaskevich
3177145c95 [CSBindings] Determine literal coverage during binding set finalization 2021-02-24 10:38:30 -08:00
Pavel Yaskevich
fbc11f410a [ConstraintSystem] Implement incremental binding computation 2021-02-24 10:37:20 -08:00
Pavel Yaskevich
df7af0078f [CSBindings] Separate inference storage from final product usable by the solver
`PotentialBindings` lost most of its responsibilities,
and are no longer comparable. Their main purpose now
is binding and metadata tracking (introduction/retraction).

New `BindingSet` type is something that represents a set
of bindings at the current step of the solver.
2021-02-24 10:37:20 -08:00
Pavel Yaskevich
55cd99bce8 [CSBindings] NFC: Adjust static member lookup feature to recent PotentialBindings changes
- `ConstraintSystem` is now referenced as a member of `PotentialBindings`;
- Literals and defaults are no longer added to the `Bindings` list, so we
  to add a new method `hasViableBindings` to make sure that protocol types
  are added only when there are no other bindings.
2021-02-23 11:33:11 -08:00
Holly Borla
11028350a7 Merge pull request #35589 from Jumhyn/placeholder-types
[AST, Sema] Replace HoleType with PlaceholderType
2021-02-22 08:35:37 -08:00
Pavel Yaskevich
321cc07ba2 [CSBindings] Reset literal coverage when retracting constraint 2021-02-17 17:26:05 -08:00
Pavel Yaskevich
8e90882ee1 [CSBindings] Allow retracting constraints previously used to compute potential bindings
This allows to avoid having to recompute bindings when solver backtracks.
2021-02-17 17:25:42 -08:00
Frederick Kellison-Linn
e4ea1678dc Rename HoleType to PlaceholderType
HoleType basically served the same purpose as PlaceholderType. This commit unifies the two.
2021-02-16 22:59:19 -05:00
Pavel Yaskevich
655aeef7ca [CSBindings] NFC: Associate isCoveredBy(PotentialBinding) with literal requirement 2021-02-16 16:57:50 -08:00
Pavel Yaskevich
b3284c6a9d [CSBindings] Track source constraint of an adjacent variable
This makes it much easier to remove adjacencies when constraint
is retracted from the bindings.
2021-02-11 15:40:19 -08:00
Pavel Yaskevich
c7169edf8f [CSBindings] NFC: Drop result type from since it's no longer useful 2021-02-09 09:09:31 -08:00
Pavel Yaskevich
df43268929 [CSBindings] Inference cannot fail
Any constraints which would previously cause binding inference to
fail should instead delay associated type variable and preserve
all of the collected information.

This is vital for incremental binding computation that cannot
re-introduce constraints after "failure" because it's too expensive.
2021-01-20 16:58:05 -08:00
Pavel Yaskevich
cb4e597921 [ConstraintSystem] NFC: Convert getPotentialBindingForRelationalConstraint into a method on PotentialBindings 2021-01-15 15:04:13 -08:00
Pavel Yaskevich
72888ca29b [ConstraintSystem] NFC: Extract PotentialBindings and auxiliary struct from ConstraintSystem
This opens up a posibility of using `PotentialBindings`
in `ConstraintGraphNode` and other places in `ConstraintGraph`.
2021-01-15 15:03:54 -08:00
Pavel Yaskevich
afec25271e [ConstraintSystem] Extract PotentialBinding and its auxiliary classes into a separate header
Create a new namespace - `swift::constraints::inference` and associate
`PotentialBinding` with it. This way it would be possible for constraint
graph to operate on `PotentialBinding(s)` in the future.
2021-01-15 15:03:24 -08:00