Deduplicate implicitly implemented interface methods in member resolution#2711
Merged
Merged
Conversation
…tion When resolving a member against a concrete type, candidate methods are collected both from the type itself and from every implemented interface. An implicitly implemented interface method was therefore added twice, showing up as a duplicated candidate signature in detailed resolution error messages (e.g. "candidate signatures: MyMethod(String a), MyMethod(String a)") and doing redundant work during overload resolution. Skip interface-sourced (and object-sourced) methods whose signature is already covered by an earlier candidate. The signature comparison is structural so generic methods match across their distinct generic parameter instances, while genuinely different methods - such as an interface method hiding an object method with a different return type - are kept. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lahma
enabled auto-merge (squash)
July 20, 2026 17:55
This was referenced Jul 22, 2026
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 the duplicated candidate signatures reported in #2523 (comment).
Problem
When a member is resolved against a concrete type,
TypeResolver.TryFindMemberAccessorcollects candidate methods both from the type itself and from every implemented interface. An implicitly implemented interface method is present in both sets, so it was added twice. WithExposeDetailedResolutionErrorsenabled a failed call then reported the same signature twice:The duplicate also meant redundant work during overload resolution since both entries bind to the same implementation.
Fix
Interface-sourced (and, for interface targets,
object-sourced) methods are now skipped when an earlier candidate already has the same signature. Because class methods are collected first, the class implementation wins, matching C# semantics for a call on the concrete type. The signature comparison is structural:Tof the class method vsTof the interface method), including through constructed generics, by-ref and array typesObject.GetHashCode()with a different return type, orEquals()overloadingEquals(object)- the existingInteropExplicitTypeTestscovering those scenarios still passThe same dedupe is applied to the explicit interface implementation path, where identical redeclared signatures from multiple interfaces could previously also be reported twice.
Testing
Added a regression test mirroring the discussion repro (interface implementation exposed through an
object-typed property). FullJint.TestsandJint.Tests.PublicInterfacesuites pass on net10.0 and net472.🤖 Generated with Claude Code