You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Overloaded extension method called in instance syntax is indexed as the first overload #134
A call to an overloaded extension method written as c.Neg(1L) is recorded with the symbol of the first overload (Neg().), although the compiler binds it to a later one. The same call in static syntax (Ext.Neg(c, 1L)) gets the correct symbol.
Run scip-dotnet index --working-directory . --output index.scip and read the occurrences of A.cs.
Observed (line, symbol written for the method name)
Call
Symbol in the index
Correct?
c.Neg(1);
Ext#Neg().
yes
c.Neg(1L);
Ext#Neg().
no, the compiler binds Neg(+1)
Ext.Neg(c, 1L);
Ext#Neg(+1).
yes
Ext.Plain(1L);
Ext#Plain(+1).
yes
So only the reduced (instance syntax) form of an extension method loses its overload disambiguator. A plausible cause is that the symbol of the reduced method is not mapped back to the original definition (IMethodSymbol.ReducedFrom) before its overload index is computed, so the index falls back to the first overload.
Effect
In a real project (a public guard-clause library, 150 sampled symbols, with Roslyn as reference) all calls of every overloaded extension method are attributed to its first overload: the first overload gets the uses of all, the others none. Eight of the sampled symbols were affected, with 139 uses according to Roslyn, of which 9 were found.
Suggested fix
Compute the overload disambiguator of a reduced extension method from ReducedFrom (or OriginalDefinition), so that c.Neg(1L) and Ext.Neg(c, 1L) produce the same symbol.
Activity
linear-code commentedon Nov 16, 2026
OSS-24232