Commit d011bf3
committed
[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.1 parent a9cce60 commit d011bf3
File tree
2 files changed
+101
-5
lines changed- include/swift/Sema
- lib/Sema
2 files changed
+101
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4708 | 4708 | | |
4709 | 4709 | | |
4710 | 4710 | | |
| 4711 | + | |
| 4712 | + | |
| 4713 | + | |
| 4714 | + | |
4711 | 4715 | | |
4712 | 4716 | | |
4713 | 4717 | | |
| |||
4873 | 4877 | | |
4874 | 4878 | | |
4875 | 4879 | | |
| 4880 | + | |
| 4881 | + | |
| 4882 | + | |
| 4883 | + | |
| 4884 | + | |
| 4885 | + | |
| 4886 | + | |
| 4887 | + | |
| 4888 | + | |
4876 | 4889 | | |
4877 | 4890 | | |
4878 | 4891 | | |
| |||
4886 | 4899 | | |
4887 | 4900 | | |
4888 | 4901 | | |
4889 | | - | |
4890 | | - | |
| 4902 | + | |
| 4903 | + | |
4891 | 4904 | | |
4892 | 4905 | | |
4893 | 4906 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
25 | 109 | | |
26 | 110 | | |
27 | 111 | | |
| |||
281 | 365 | | |
282 | 366 | | |
283 | 367 | | |
284 | | - | |
285 | | - | |
| 368 | + | |
286 | 369 | | |
287 | 370 | | |
288 | 371 | | |
289 | 372 | | |
290 | 373 | | |
291 | 374 | | |
292 | 375 | | |
| 376 | + | |
293 | 377 | | |
294 | | - | |
295 | 378 | | |
296 | 379 | | |
297 | 380 | | |
| |||
0 commit comments