Commit 02696c9
committed
[CSBindings] Downgrade key path mutability based on contextual information
If key path literal is converted to a read-only type, let's not
use maximum mutability to avoid unnecessary conversions. This is
also important because accessor references are availability checked
and we need to avoid referencing something that is not actually
going to be used.
There are some edge-cases in this approach which would still
produce a conversions, i.e.:
```
struct S {
var a: Int
let b: Int
}
func test<T>(_: T, _: T) {}
test(\S.a, \S.b)
```
Here `\S.a` is going to be converted to `KeyPath<S, Int>`. Availability
checker would still have to recognize situations like that and skip
checking setters if they are not used.1 parent cf3dab1 commit 02696c9
File tree
3 files changed
+30
-7
lines changed- lib/Sema
- test
- Concurrency
- SILGen
3 files changed
+30
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
| 724 | + | |
724 | 725 | | |
725 | 726 | | |
726 | 727 | | |
| |||
740 | 741 | | |
741 | 742 | | |
742 | 743 | | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
743 | 748 | | |
744 | 749 | | |
745 | 750 | | |
746 | 751 | | |
747 | 752 | | |
748 | 753 | | |
749 | | - | |
| 754 | + | |
750 | 755 | | |
751 | 756 | | |
752 | 757 | | |
753 | 758 | | |
754 | 759 | | |
755 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
756 | 768 | | |
757 | 769 | | |
758 | 770 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
741 | | - | |
| 741 | + | |
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
745 | | - | |
| 745 | + | |
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
| |||
0 commit comments