Fix #2078: Generic local functions not highlighted properly - #3857
Merged
Conversation
LocalFunctionMethod.MemberDefinition returned the instance itself, so the declaration of a generic local function (whose base method is an identity specialization) and its use sites (whose base methods carry the use-site substitutions) never compared equal, and click-highlighting could not group them. Returning a wrapper around the unspecialized base method lets the token writer record the same definition object for the declaration and all use sites. Method-group references to local functions additionally need their own lookup, because GetSymbol() does not surface a MethodGroupResolveResult. The token-writer tests now keep the PEFile alive for the duration of each test: recorded references are type-system entities that lazily read from the PE image, and formatting one in an assertion message after disposal crashed with an AccessViolationException. Assisted-by: Claude:claude-fable-5:Claude Code
siegfriedpammer
force-pushed
the
fix-2078-local-function-highlighting
branch
from
July 4, 2026 19:06
5261483 to
f1b2737
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2078.
LocalFunctionMethod.MemberDefinitionreturned the (possibly specialized) instance itself, so the declaration of a generic local function and its use sites never compared equal, and the text view could not group them for click-highlighting: the declaration's base method is an identity specialization, while every call/ldftn site carries the use-site substitution.Changes:
LocalFunctionMethod.MemberDefinitionnow returns aLocalFunctionMethodwrappingbaseMethod.MemberDefinition(orthiswhen the base method already is the definition).TextTokenWriter.GetCurrentLocalDefinition/GetCurrentLocalReferencerecord thatMemberDefinition, so the declaration and all use sites share equal reference objects. Method-group references to local functions (delegate conversions) are now surfaced as local references at all:GetSymbol()returns null for aMethodGroupResolveResult, so they previously were not clickable.PEFilealive while assertions run; formatting a recorded type-system object after disposal crashed with anAccessViolationException.Verified on Linux: full ICSharpCode.Decompiler.Tests (2305) and ILSpy.Tests (977) suites green.
This PR was prepared by an AI agent (Claude Code) operated by @siegfriedpammer.
🤖 Generated with Claude Code