|
| 1 | +# Subscription whose `-=` sits in the never-attached overload of an ambiguously-named wired handler (soundness FN) |
| 2 | + |
| 3 | +**Pattern (#278 follow-up 2 — the unresolved-overload fallback blocker).** The |
| 4 | +class wires `Closing += Window_Closing` where the lifecycle event does NOT |
| 5 | +resolve (WPF `Window` base on a Linux runner without the reference pack), and |
| 6 | +declares TWO `Window_Closing` overloads. A method group syntactically denotes |
| 7 | +its whole overload set, but the runtime delegate attaches exactly ONE member — |
| 8 | +selected by the event's delegate signature, which is precisely the information |
| 9 | +the extractor is missing. Here the delegate-compatible overload |
| 10 | +(`(object, CancelEventArgs)`) detaches nothing, and the `-=` sits in the other, |
| 11 | +never-attached overload. |
| 12 | + |
| 13 | +**The bug.** The previous slice's unresolved-event fallback added EVERY |
| 14 | +same-named own method to the teardown set, so the `-=` in the never-attached |
| 15 | +overload was silently credited as a release — the unresolved twin of the |
| 16 | +invocation-overload conflation pinned by |
| 17 | +`subscription-overload-conflated-cleanup`. |
| 18 | + |
| 19 | +**The fix.** When the handler binds no definite symbol, the name grounds a |
| 20 | +teardown ONLY if it is unambiguous — exactly one `IMethodSymbol` with that name |
| 21 | +in the immediate class. Zero or 2+ matches credit nothing and keep the honest |
| 22 | +warning. The symbol-resolved path is unchanged: when the event resolves, the |
| 23 | +delegate's exact target is credited even among overloads (pinned in the smoke |
| 24 | +matrix; `subscription-xaml-name-only-release/after.cs` keeps the resolved |
| 25 | +single-handler control). The prior fallback's `CandidateSymbols` crediting is |
| 26 | +gone with it — candidates of a failed method-group binding are the same |
| 27 | +ambiguous overload set by another name. |
| 28 | + |
| 29 | +**`before.cs`** → OWN001 (ambiguous, `-=` unproven). **`after.cs`** — the |
| 30 | +positive control: same unresolved event, exactly one `Window_Closing`, `-=` |
| 31 | +inside it → silent (whichever overload the delegate would pick, it is that |
| 32 | +one). Both keep the usual OWN050 advisory for the unresolved `Closing +=` |
| 33 | +itself. |
| 34 | + |
| 35 | +**What the checker says (`.own` reduction).** The scope acquires the token and |
| 36 | +the executed teardown path performs no release => **OWN001** with the |
| 37 | +subscription-token resource tag. |
| 38 | + |
| 39 | +**Regression guard.** `scripts/benchmark.py`: `before.cs` must be **caught**, |
| 40 | +`after.cs` must be **silent**. |
0 commit comments