Repository navigation
Commit 102c564
committed
fix(swift): keep the label match for a constructor-typed receiver
A receiver typed only by its constructor call (`let x = Foo()`, also
through `try` / `await`) now narrows the label match the way a receiver
with an inferred initializer type already does: a member the type has
still wins, and when the type has no member with the call's name and
labels, the call keeps the label match instead of getting no edge. One
such site is Alamofire's Session.swift:1389, where `mutableState` is a
`Protected(...)` whose members the parser leaves as free functions.
This applies only to a type the project declares. A constructor of a
type the project does not know (DispatchSemaphore(), Task {...}) or only
extends (Data()) still gets no edge: on swift-nio and Alamofire a label
match for those receivers mostly lands on unrelated project methods,
for example `semaphore.wait()` on EventLoopFuture.wait. A name the
extractor reads as a constructor but that resolves to a project function
(`Foo.make()`) keeps the label match like an inferred call result.
Annotations and parameters still decide alone, and inferring an
initializer's type still never uses a label match. The extractor marks a
binding as `constructed` when its type comes from the initializer's
constructor call rather than from an annotation.
On swift-nio eabcc14f and Alamofire bda9ed57 this adds 947 and 166 call
edges and removes none. pipeline_swift_constructor_receiver_keeps_label_match_issue2061
(sequential and parallel) pins the fallback, a member that still wins,
and the annotated, parameter, unknown-type and extended-type cases.
Signed-off-by: Martin Vogel <[email protected]>1 parent bbd727f commit 102c564
4 files changed
Lines changed: 88 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| 582 | + | |
| 583 | + | |
582 | 584 | | |
583 | 585 | | |
584 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3688 | 3688 | | |
3689 | 3689 | | |
3690 | 3690 | | |
3691 | | - | |
3692 | | - | |
| 3691 | + | |
| 3692 | + | |
3693 | 3693 | | |
3694 | | - | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
3695 | 3700 | | |
3696 | 3701 | | |
3697 | 3702 | | |
| |||
3721 | 3726 | | |
3722 | 3727 | | |
3723 | 3728 | | |
3724 | | - | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
3725 | 3735 | | |
3726 | 3736 | | |
3727 | 3737 | | |
| |||
4169 | 4179 | | |
4170 | 4180 | | |
4171 | 4181 | | |
| 4182 | + | |
| 4183 | + | |
| 4184 | + | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
| 4193 | + | |
| 4194 | + | |
| 4195 | + | |
| 4196 | + | |
| 4197 | + | |
| 4198 | + | |
| 4199 | + | |
| 4200 | + | |
| 4201 | + | |
| 4202 | + | |
| 4203 | + | |
| 4204 | + | |
| 4205 | + | |
| 4206 | + | |
| 4207 | + | |
| 4208 | + | |
4172 | 4209 | | |
4173 | 4210 | | |
4174 | 4211 | | |
| |||
4203 | 4240 | | |
4204 | 4241 | | |
4205 | 4242 | | |
4206 | | - | |
4207 | | - | |
4208 | | - | |
4209 | | - | |
| 4243 | + | |
4210 | 4244 | | |
4211 | 4245 | | |
4212 | 4246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17753 | 17753 | | |
17754 | 17754 | | |
17755 | 17755 | | |
| 17756 | + | |
| 17757 | + | |
| 17758 | + | |
| 17759 | + | |
| 17760 | + | |
| 17761 | + | |
| 17762 | + | |
| 17763 | + | |
| 17764 | + | |
| 17765 | + | |
| 17766 | + | |
| 17767 | + | |
| 17768 | + | |
| 17769 | + | |
| 17770 | + | |
| 17771 | + | |
| 17772 | + | |
| 17773 | + | |
| 17774 | + | |
| 17775 | + | |
| 17776 | + | |
| 17777 | + | |
| 17778 | + | |
| 17779 | + | |
| 17780 | + | |
| 17781 | + | |
| 17782 | + | |
| 17783 | + | |
| 17784 | + | |
| 17785 | + | |
| 17786 | + | |
| 17787 | + | |
| 17788 | + | |
| 17789 | + | |
| 17790 | + | |
| 17791 | + | |
| 17792 | + | |
| 17793 | + | |
| 17794 | + | |
| 17795 | + | |
| 17796 | + | |
17756 | 17797 | | |
17757 | 17798 | | |
17758 | 17799 | | |
| |||
33883 | 33924 | | |
33884 | 33925 | | |
33885 | 33926 | | |
| 33927 | + | |
33886 | 33928 | | |
33887 | 33929 | | |
33888 | 33930 | | |
| |||
0 commit comments